Comunidad de diseño web y desarrollo en internet online

Button-s dinamicos con actionscript

Citar            
MensajeEscrito el 05 Jul 2007 09:56 am
Tengo un problemilla. Con un for he ido creando botones con un Button que tenía en la biblioteca. Le he id o d ando un nombre diferente a cada uno. Ahora lo q ue quiero es que al seleccionarlo pueda visualizar una fot o. La cosa es que cuando lo presiono no me hace nada. Que puede ser?? Pongo el código y así sabeis si hay errores.

Código:
function rellenar(){
var i:Number;
var total:Number;
var y:Number;
var x:Number;
var conta:Number;
x=0;
conta=0;
var titulo_txt:TextField;
var fecha_txt:TextField;
var btn_dat:MovieClip;
y=5;
total=dataNoticias.arrayNoticias.length;
for(i=total; i > 0 ; i--){
if (conta==4){
}
else{
conta++;
y=y+50;
btn_not=attachMovie("Button","btn_not"+i,x++);
btn_not._x=40;
btn_not._y=y;
btn_not.name="btn"+i;
btn_not.setSize(260, 20);
btn_not._alpha=15;
btn_not.setStyle("themeColor", "0xD5D5D5");
btn_not.useHandCursor=true;
btn_not.label=dataNoticias["noticia"+i].titulo;
btn_not.labelPlacement = "left";
btn_not.selectable=true;
_root.contenido02.createTextField("fecha_txt"+i,x++,50 ,y+15,260,18);
fecha_txt=_root.contenido02["fecha_txt"+i];
crear(fecha_txt,dataNoticias["noticia"+i].fecha);
name_txt.text=btn_not.name;
}
}
}

function crear(txt:TextField,dato:String){
var txtf:TextFormat = new TextFormat;
txt.text=dato;
txt.background=true;
txt.backgroundColor=0xD5D5D5;
txtf.color=0x016975;
txtf.font="Gill Sans MT";
txtf.size=12;
txt.multiline=false;
txt.selectable=false;
txt.setTextFormat(txtf);
}
btn_not.onPress = function(){
name_txt.text=btn_not._name;
}

El btn_not lo tengo declarado como global y MovieClip. No se si esta bien o hay algun fallo?? Si alguien me puede ayudar se lo agradeceria. Un saludo y gracias. :lol:

Por vega

20 de clabLevel



 

msie
Citar            
MensajeEscrito el 10 Jul 2007 03:32 pm
La función del onPress debes ponerla en donde creas el botón y modificarla con "this" (dentro de la función "rellenar"):

Código :

btn_not.selectable=true; 
btn_not.onPress = function(){
   name_txt.text=this._name;
}

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7

 

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