I have a flash file that has three main buttons on top. When a button is clicked the timeline moves to a that frame (designated with a label) that loads in a particular external SWF corresponding with the button. Those movies are loaded into the same empty movieclip called “presentation” using:
loadMovie("splash.swf","presentation");
In one of the external loaded SWF’s there is a tween animation (on first frame using TweenLite), that takes place upon loading the SWF. The issue is that when I click a button and go to another frame (which loads another SWF) mid-way through that animation, and come back to that same page with the animation. The animations starts mid-way as if it was running in the back, such as fading in things that shouldn’t be faded in yet, etc..? Any clue as to why?
EDIT: Maybe this is the cause? The animation code in the first frame of the loaded SWF:
//Animate the bouquet
var bFadeIn:Tween = new Tween(bouquet,"_alpha",Back.easeInOut,0,100,1,true); //106.95
bFadeIn.onMotionFinished = function() {
for(var i=1; i < 12; i++) {
TweenLite.to(bouquet["olddot"+i], 1, {_x:96.25, _y:94.05, _alpha: 0, ease:Back.easeInOut});
}
TweenLite.to(bouquet.chip, 1, {_alpha:0, delay:1, onComplete:newDotsAnimate});
}
function newDotsAnimate() {
TweenLite.to(bouquet.phone,1, {_alpha:100, ease:Back.easeOut, delay:.3});
bouquet.phone._visible = true;
TweenLite.to(bouquet.newdot1, 1, {_alpha:100, _x:127.95, _y:23, ease:Back.easeOut, delay:1});
TweenLite.to(bouquet.newdot2, 1, {_alpha:100, _x:226.45, _y:101.50, ease:Back.easeOut, delay:1});
TweenLite.to(bouquet.newdot3, 1, {_alpha:100, _x:188.70, _y:216.60, ease:Back.easeOut, delay:1});
TweenLite.to(bouquet.newdot4, 1, {_alpha:100, _x:59.95, _y:216.90, ease:Back.easeOut, delay:1});
TweenLite.to(bouquet.newdot5, 1, {_alpha:100, _x:26.95, _y:100.95, ease:Back.easeOut, delay:1});
TweenLite.to(bouquet_instructions,1,{_alpha:100}); //fade in the instructions, then fade them out
}
Your loaded SWF is going to stop in place where you left it. Going back to the frame showing it will cause it to resume where it left off unless you called gotoAndStop(1). This is because the SWF isn’t being unloaded and reloaded every time you navigate on the timeline.
Your best bet, if possible, is to create a cleanup() or hide() method for your loaded SWF(s) that gets called whenever the main SWF navigates away from them. That way your loaded SWF content can disable itself (stop playing sounds, stop playing on the timeline, etc). By implementing this function themselves the loaded SWFs take responsibility for their “reset” conditions, and all the loading SWF has to do is call “loadedSWF.cleanup()”.