actionscript 3 - Delete MC loaded in runtime -


I have loaded a library's movie clip on this forum with this code:

  addChildAt (MC_1, 0);  

In this, the movie clip is used as a few movie clips button when I click on one of the buttons If I press, it changes color (goto frames 2).

After this, I deleted the code from the MC_1 forum like this:

  removeChildAt (0);   

and MovieClip have been loaded like MC_1 :

  addChildAt (MC_2, 0 );  

The problem is that, if I load another MC_1 , then the last button is pressed still still colorful.

How can I completely unload it from memory?

Apparently you are not loading the other MC_1 , you are adding the same example which is referred to by MC_1 is not just adding a movie clip "Loading", it is also immediately To do this, you type MC_1 = new something (); Therefore, to add a completely new movie clip to the library, you get the MC_1 = new something () where something is the name of the movie clip in the library < / P>

You can also create a different perspective: You give the prototype a task that will react to the event Event.REMOVED_FROM_STAGE , which can change all the buttons in MC to its states Default is like this:

  The public class comes in anything Movie Clip { // Some other functionality here is the public function (some) {// ... addEventListener (Event.REMOVED_FROM_STAGE, reset MC); } Private Function ResetM (E: Event): Zero {button_1.gotoAndStop (1); Make sure to put the proper name of the / / button ... // place a gotoAndStop () per button call you want to switch back}}  

Then, as soon as you remove The child (MC_1) , kicks this code, which contains all the MC_1 buttons (OK, which are referred to in the resetMC () function) the same frame To show (here, button_1 will show the first frame). This approach is usually better, because you do not create a new example to appear in memory, thus you can control current MC_1 .


Comments