-
be sure mc is added to stage before controlling it?
Hi,
if I do this to add a movieclip are there any issues with immediately saying clip.gotoAndPlay(2)?
could the play be fired before the clip is added fully?
If so how do you deal with that?
PHP Code:
clip = MovieClip(sectionArray[nextBanner].content);
banners_mc.removeChildAt(0);
banners_mc.addChild(clip);
thanks
mark
-
Total Universe Mod
The only real limitations to dealing with descendants of DisplayObject who are not on a display list is dealing with their .stage property since it will be null and changing their depth (swapChildren(), setChildIndex(), etc.). Otherwise timeline control is in tact and the only risk is not seeing some frames while it's being added to the list.
You can always just listen for the ADDED_TO_STAGE event.
Actionscript Code:
clip.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); function onAddedToStage(e:Event):void{ clip.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); clip.gotoAndPlay(2); }
-
thanks that was exactly what I was looking for.
-
I have run into a problem, when I add the added_to_stage function it does not get called? clip is getting added to the stage.
If I remve the added to stage and use the commented out clip.gotoAndStop(2) in the swapItem function it works.
PHP Code:
function swapItem(evt:Event):void {
clip.gotoAndStop(1);//remove old clip
clip.removeEventListener("All Done", swapItem);
banners_mc.removeChildAt(0);
clip = MovieClip(sectionArray[nextBanner].content);
banners_mc.addChild(clip);
clip.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
clip.addEventListener("All Done", swapItem);
//clip.gotoAndStop(2);
clearAllButtonStates();
if (currentBanner < sectionArray.length - 1) {
currentBanner++;
} else {
currentBanner = 0;
}
if (nextBanner < sectionArray.length - 1) {
nextBanner++;
} else {
nextBanner = 0;
}
numBtnArray[currentBanner].gotoAndStop("Selected");
previousNumBtn = numBtnArray[currentBanner];
}
function onAddedToStage(e:Event):void{
clip.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
clip.gotoAndStop(2);
trace("added to stage");
}
-
DOH!
I needed to add the event listener before doing addChild.
PHP Code:
clip = MovieClip(sectionArray[nextBanner].content);
clip.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
banners_mc.addChild(clip);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|