actionscript 3 - as3 accessing Children from dynamicly added moiveclip -


i adding moiveclips , putting position accordingly. placing dynamically added clips in 1 new movie clip , centering on stage. test, see can control alpha in main container can not access children. how can assess each flagbutton separately? there several in loop example below.

var flagbutton:movieclip; var flagarray:array = new array; var flagdisplaybuttons:movieclip = new movieclip(); function displayflagbuttons() {     for( var = 0; flagarray.length > i; i++) {     var flagbutton:movieclip = new roundbutton();     flagbutton.x = (flagbutton.width + 10) * i;     flagbutton.y = stage.stageheight - flagbutton.height;     addchild(flagbutton);      flagdisplaybuttons.addchild(flagbutton); } addchild(flagdisplaybuttons);  // works flagdisplaybuttons.x = stage.stagewidth/2 - flagdisplaybuttons.width/2;  // not see flagbutton flagdisplaybuttons.flagbutton.alpha = .5; } 

gets error: typeerror: error #1010: term undefined , has no properties.

in example code, have created bunch of button instances, , 1 one have added them display list of flagdisplaybuttons. on display list in order placed them.

first instance @ index 0

second instance @ index 1

third instance @ index 2

and on.

so if want access third button added, :

var flagbutton:roundbutton = flagdisplaybuttons.getchildat(2) roundbutton; 

now have created variable reference button, can of these :

flagbutton.alpha = .5; flagbutton.x = 100; flagbutton.y = 200; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -