lundi 22 février 2016

create different buttons in the runtime using actionscript

I need to create a number of buttons in the run time, each button has its own behavior like the style and the functionality what function shoud i use to give instance name to the button? as when i trace the name target it generated randomly as instance2 , instance6 and so on thank you

here is what i tried i create a class called glosbtn

import flash.events.MouseEvent;
import flash.events.Event;

for(var i:int=0;i<4;i++)
{
    for(var j:int=0;j<6;j++)
{
var btn:glosbtn= new glosbtn();
addChild(btn);
btn.x=50*j;
btn.y=50*i;
btn.addEventListener(MouseEvent.CLICK,glosbtnclick)

}
}

function glosbtnclick(e:Event){
    trace(e.target.name)
    // do my stuff
}

Aucun commentaire:

Enregistrer un commentaire