Código :
package clases { import flash.utils.*; import flash.text.*; import flash.events.*; import flash.display.Sprite; import flash.net.*; import flash.display.*; public dynamic class bot extends Sprite { public dynamic function bot(){ var r01:uint; var r02:uint; var k1:uint; var k2:uint; var spr02:Sprite=new Sprite; var n:uint; var st01:Array=new Array('yuxtaposició','pрпак','teclat','colom','arreboire','contingut','blau','rentadora','cadira','ratoli','jerro','id¶☺a','pare','teclat','malson','desgracia','finestra','taronja','caball','lampada','escacs','tintorera','ura','plati','esquema','llantia','mag','electro','cantar','rodona'); var formatoTexto:TextFormat=new TextFormat(); for(n=0;n<=29;n++){ if((n>=0)&&(n<=9)){ r01=n; r02=0;} if((n>=10)&&(n<=19)){ r01=(n-10); r02=1;} if((n>=20)&&(n<=29)){ r01=(n-20); r02=2;} k1=r01*22; k2=r02*266; this['spr'+n]=new Sprite; this['tf'+n]=new TextField(); formatoTexto.color=0x000000; formatoTexto.size=11; formatoTexto.align='center'; formatoTexto.font='courier new'; formatoTexto.bold=false; this['tf'+n].defaultTextFormat=formatoTexto; this['tf'+n].textColor = 0x000000; this['tf'+n].x=25+k2; this['tf'+n].y=260+k1; this['tf'+n].border=true; this['tf'+n].text = st01[n]; this['tf'+n].width=220; this['tf'+n].height=20; this['tf'+n].background=true; this['tf'+n].backgroundColor=0xffffff; this['tf'+n].borderColor=0xa5a5a5; this['tf'+n].name='tf'+n; this['spr'+n].addChild(this['tf'+n]); this['spr'+n].buttonMode=true; this['spr'+n].mouseChildren=false; this['spr'+n].addEventListener(MouseEvent.ROLL_OUT,out); this['spr'+n].addEventListener(MouseEvent.ROLL_OVER,over); this['spr'+n].addEventListener(MouseEvent.CLICK,pulsado); this['spr'+n].name='t'+n;spr02.addChild(this['spr'+n]);} var ftt:TextFormat=new TextFormat(); var tfc:TextField=new TextField(); ftt.align='center'; ftt.size=20; ftt.font='courier new'; tfc.defaultTextFormat=ftt; tfc.text='horse'; tfc.x=215; tfc.y=200; tfc.selectable=false; tfc.border=true; tfc.width=370; tfc.height=25; spr02.addChild(tfc); addChild(spr02);} public function over(evt:MouseEvent){this['tf'+evt.target.name.substr(1)].backgroundColor=0xf1f1f1;}; public function out(evt:MouseEvent){this['tf'+evt.target.name.substr(1)].backgroundColor=0xffffff;}; public function pulsado(evt:MouseEvent){navigateToURL(new URLRequest("http://www.google.es"));}; }}
el archivo este se llama bot.as que se encuentra en un directorio "clases" como indica el package, luego el fla con el siguiente codigo
Código :
import clases.*; var a:bot=new bot(); addChild(a);
todo correcto y me funciona a la perfeccion, ahora la pregunta del millon como puedo hacer para que cada haya una direccion diferente para cada click de boton, supongo que debo crear un array de direcciones que podria ser
Código :
var st02:Array=new Array ('http://www.google.es','http://www.yahoo.es','http://www.wikipedia.es','.......');como debo asignar una funcion dinamica tendre que poner en vez de
Código :
public function pulsado(evt:MouseEvent){navigateToURL(new URLRequest("http://www.google.es"));};poner
Código :
public dinamic function pulsado{....}de antemano gracias por leerme