actionscript 3 - addChild communicate with inner movieClips -
i have problems as3. have movieclip , have added stage addchild(gamelevelselect);.
the thing have other movieclips inside not addchild in addchild(gamelevelselect); on stage. gave symbol instance name of stagethumb_01, not work. how can fix that?
this code:
gamelevelselect.getchildbyname("stagethumb_01").addeventlistener(mouseevent.click, load_level01); function load_level01(e:mouseevent):void { trace("blam") gamelevelselect.getchildbyname("stagethumb_01").getchildbyname("stars").gotoandplay(2); } .................................................
gametitle.addeventlistener(event.enter_frame, load_levelselection); function load_levelselection(event:event):void { if(movieclip(gametitle).currentframe == 22){ removechild(gametitle); addchild(gamelevelselect); addchild(thumblevel01); thumblevel01.getchildbyname("stars").gotoandplay(1); gamelevelselect.gotoandplay(1); } } var thumblevel01 = new stagethumb01(); thumblevel01.x = 83; thumblevel01.y = 161; thumblevel01.addeventlistener(mouseevent.click, load_level01); function load_level01(e:mouseevent):void { trace("blam") //thumblevel01.getchildbyname("stars").gotoandplay(2); } this works , reason made thumblevel01 addchild. not want. have movieclip added stage addchild(gamelevelselect); , in movieclip there animations , buttons , instead of doing linkage want keep movieclip in addchild(gamelevelselect);. want know how can communicate movie clips instance name in addchild(gamelevelselect);. have tried
gamelevelselect(theaddclass).getchildbyname("thumblevel01").getchildbyname("stars").<..stars movieclip in thumblevel01. addeventlistener(mouseevent.click, load_level01);
[addchild - gamelevelselect] . . . . . . . > movieclip instance name - thumblevel01 (not add child). . . . . . . . .> movieclip instance name - starsmeter (for score).
the way you've asked question pretty obtuse, can't core of you're asking, suspect what's going on you're trying access children before they're added stage of instance you've added through code.
in general, don't want directly access children. instead, component added should expose properties , methods allow need do, take account specific details of how mc built. example:
class showmessage extends movieclip { public var tf:textfield;//this public flash player can fill it, not external use private var _message:string; public function message():string { return _message; } public function set message(value:string):void { _message = value; if (tf) { tf.text = value; } } } for other ways handle mixture of timeline , as, check out combining timeline oop in flash.
Comments
Post a Comment