Copy link to clipboard
Copied
Hello all,
I've got a situation where I have multipe MC's on the same frame... each is animated and doing something different. As the user interacts with them, I'd like a way (when cued) to reset the MC back to it's initial state - not gotoAndStop("MC frame 1"); - but actually set it like it's running for the first time.
Is there a command to resetMovieClip? I need this reset not to affect the other MC's that are running simultaneously.
Thanks in advance for taking a look!
Best,
Copy link to clipboard
Copied
Hi.
What exactly do you need to be reset other than the current frame?
Regards,
JC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The general case is that when you add something and set any listeners going, you need to remove those listeners when you remove the object.
As an abstract example, you might have this:
stage.addEventListener(Event.ADDED_TO_STAGE,setup);
function setup(e:Event){
stage.removeEventListener(Event.ADDED_TO_STAGE);
//set up some timers and other listeners
stage.addEventListener(Event.REMOVED_FROM_STAGE,destroy);
}
function destroy(e:Event){
stage.removeEventListener(Event.REMOVED_FROM_STAGE);
//remove any of the listeners you set up when added to stage.
}
That is all just email code, and not a copy and paste from something I've done before. So take it as a guide.
Copy link to clipboard
Copied
Colin, I've scripted this to end the timers and remove the event listener on a keystroke but the timers still seem to be running in the BG. Would you mind taking a look at my function see if you can spot a problem?
stage.addEventListener(KeyboardEvent.KEY_DOWN, stateHandler);
function stateHandler(event:KeyboardEvent):void {
if (MovieClip(root).oneKey == true && event.keyCode == 78) {
alert_time.stop();
normal_time.stop();
alert_time.removeEventListener(TimerEvent.TIMER_COMPLETE, alertTimer);
MovieClip(root).oneKey = false;
gotoAndStop("normalMode");
}