• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

way to Completely 'Reset' a MovieClip

Participant ,
Oct 01, 2019 Oct 01, 2019

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,

 

Views

974

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

Hi.

 

What exactly do you need to be reset other than the current frame?

 

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

Several things including some timers, counters, etc. These are still firing when you jump back to the first frame of the MC. I'm looking for an easier way to 'reset' the MC and was hoping there's a command that accomplishes that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 01, 2019 Oct 01, 2019

Copy link to clipboard

Copied

If the movie clips have code to take care of those things when they are removed from the stage, an easy solution would be to remove the current one, and add a new one. That would assume that they are symbols in the library, and you can do addChild(new Thingy() as MovieClip) as the way you add them to the scene.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Thanks for the suggestion Colin! So I'm still an AS3 newb so learning as I build... can you explain or point the way to more nfo on this method. Note: I've used the addChild method in the past to bring objects to the front of the stage but I'm not clear how using addChild in this situation would work exactly?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Colin and anyone listening... So I figured out how to turn my MC into a class and bring it to the stage and remove it, etc. Seems when I remove the MC and bring it back later using the addChild method, my timers, counters, etc. are still running in the BG and aren't reset which is what I was wanting to do easily. Any other suggestion? Thanks!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 02, 2019 Oct 02, 2019

Copy link to clipboard

Copied

Seems like you will need to create a function within a conditional statement. The function can reset the counter, start the movieclip from frame 1, and any other instructions YOU give it within that function. The function would be called if the user mouses over the instance name of whatever MC you select. There is no auto reset. But this is easy enough to accomplish.
Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2019 Oct 02, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 04, 2019 Oct 04, 2019

Copy link to clipboard

Copied

LATEST

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");

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines