I have some problems with AS3. I have a Movieclip and I have added it to the stage with addChild(gameLevelSelect);
.
The thing is I also have other MovieClips inside it but not as addChild just in that addChild(gameLevelSelect);
on the stage. I gave a symbol a instance name of stageThumb_01
, but it does not work. How can I fix that?
This is the 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 and the reason is that i made thumbLevel01 a addChild. But this is not what i want. i have a movieclip added to the stage as a addChild(gameLevelSelect); and in that movieclip there are animations and buttons And instead of doing a linkage i want to keep it as a movieclip in addChild(gameLevelSelect);. What i want to know is how can i communicate with the movie clips with instance name in addChild(gameLevelSelect);. i have Tried
gameLevelSelect(theAddClass).getChildByName("thumbLevel01").getChildByName("stars").<..stars is a movieClip in thumbLevel01. then addEventListener(MouseEvent.CLICK, load_Level01);
[addChild - gameLevelSelect] . . . . . . . > movieClip with instance name - thumbLevel01 (not add child). . . . . . . . .> movieClip with instance name - starsMeter (for score).
gameLevelSelect
variable with the addChild in your code sample might be helpful. – Jason Sturges