Comunidad de diseño web y desarrollo en internet online

Cambiar los valores de los GetUrl al pulsar un botón

Citar            
MensajeEscrito el 07 Oct 2009 04:17 pm
Hola.
Me gustaría saber si existe algún modo de que al pulsar en un botón, todos los demás botones que tienen asociado un GetUrl, cambien la Url a la que apuntan, por otras .
Gracias por la ayuda.
Juan

Por lesta

15 de clabLevel



 

firefox
Citar            
MensajeEscrito el 07 Oct 2009 04:26 pm
Si se puede. El link es un string no? entonces lo q puedes hacer es tener una lista de links dentro de un array

Al presionar un boton mandarias llamar una funcion que haga un recorrido (for, while, ...) buscando el link asociado a cada boton y si encuentra coincidencia con el boton pulsado entonces recurrir al array para asociar otro link

Por comicSans

Claber

151 de clabLevel



 

chrome
Citar            
MensajeEscrito el 07 Oct 2009 04:34 pm
gracias comicSans.
La verdad es que creo que es demasiado complejo para mi poco conocimiento de AS...
¿Conoces algún tutorial donde pueda apreder a hacer lo que dices?

Un saludo
Juan

Por lesta

15 de clabLevel



 

firefox
Citar            
MensajeEscrito el 07 Oct 2009 07:58 pm
Hola Juan, mirate este codigo, pegalo en tu 1er frame y dale Ctrl+Intro, se forman botones que al ser pulsados verifican cual tiene algun link similar, es lo q te comentaba de meter los links en algun array e irlo recorriendo para verificar cuales se repiten

Código ActionScript :

var links:Array = new Array('link1', 'link2', 'link3', 'link4', 'link5', 'link6', 'link7', 'link8', 'link9', 'link10');
var str_btns_var:String = '';

function formarBtns(){
for (var i:Number=0; i<links.length; i++)
{
var boton:MovieClip = _root.createEmptyMovieClip('boton'+i, i);
boton.beginFill(0x0000FF, 100);
boton.moveTo(0, 0);
boton.lineTo(20, 0);
boton.lineTo(20, 20);
boton.lineTo(0, 20);
boton.endFill();
boton._x = boton._width + Number(boton._width+5)*i;
boton._y = boton._height/2;

linkTo = links[random(links.length)]
boton.varlink = linkTo;
boton.onRelease = function () { validarLinks(this._name) }

str_btns_var += Number(i+1)+'. boton'+i+' --> '+linkTo + newline;
}
}
formarBtns();

var status_txt:TextField = _root.createTextField('status_txt',_root.getNextHighestDepth(),50,50,200,300);
status_txt.border = status_txt.html = true;
status_txt.htmlText = '<u>botones links</u>:'+newline+str_btns_var;

var update_txt:TextField = _root.createTextField('update_txt',_root.getNextHighestDepth(),260,50,200,300);
update_txt.border = update_txt.html = true;
update_txt.htmlText = '<u>new links links</u>:';

function validarLinks(param:MovieClip)
{
str_btns_var = '';
clip = eval(param);
// trace(param + ', ' + clip.varlink);

  for (var i:Number=0; i<links.length; i++)
  {
  var boton:MovieClip = eval('boton'+i);
  boton.enabled = true;
  boton._alpha = 100;
  
    // Aqui busca links repetidos
   if (boton==clip)
   {
   str_btns_var += param + ' pulsado, <font color="#ff0000">URL: ' + clip.varlink +'</font>'+ newline;
   boton.enabled = false;
   boton._alpha = 50;
   } else 
   {
     if(clip.varlink==boton.varlink)
     {
     eleccion = ' <font color="#ff0000">==</font> ';
     boton.enabled = false;
     boton._alpha = 50;
     } else {
     eleccion = ' <font color="#0000ff">!=</font> ';
     }
   str_btns_var += clip.varlink + eleccion + boton.varlink + newline;
   }

  update_txt.htmlText = '<u>new links links</u>:'+newline+str_btns_var;
  }
}

// RESET
var resetBtn:MovieClip = _root.createEmptyMovieClip('resetBtn', _root.getNextHighestDepth());
resetBtn.beginFill(0xFF0000, 100);
resetBtn.moveTo(0, 0);
resetBtn.lineTo(20, 10);
resetBtn.lineTo(0, 20);
resetBtn.endFill();
resetBtn._x = _root['boton'+[links.length-1]]._x + 30;
resetBtn._y = _root['boton'+[links.length-1]]._height/2;
resetBtn.onRelease = function () {
  str_btns_var = '';
  formarBtns();
  update_txt.htmlText = '<u>new links links</u>:';
  status_txt.htmlText = '<u>botones links</u>:'+newline+str_btns_var;
}


Yo te sugeriria que le echaras un vistazo mas a fondo a actionscript para que le entiendas mejor, asi puedas manipular tus codigos u otros. Salu2!

Por comicSans

Claber

151 de clabLevel



 

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.