Animating Dynamic MovieClips - Page 7
       by kirupa  |  30 August 2006

In this page we will continue the code explanation from the previous page. The end for these explanations is almost near though, so stay patient.


inputMC._xscale += 10;
inputMC._yscale += 10;

In the above lines, I am increasing inputMC’s x and y scaling. Because I want the scaling to be uniform, I am incrementing both the _xscale and _yscale properties by the same value, 10.


inputMC._alpha -= 1;

Like the two lines above it, this time, I am decreasing our inputMC movie clip’s alpha property by 1. While decreasing by one might not seem like a lot, remember that this line and the above two lines are executed 25 times a second!


if (inputMC._alpha<0) {
inputMC.removeMovieClip();
delete inputMC.onEnterFrame;
}

This if statement becomes true if the alpha property of our movie clip drops below zero. In another way of phrasing this, the if statement is true when our input movie clip becomes invisible.


inputMC.removeMovieClip();

In this line, I invoke the removeMovieClip() method to remove the inputMC movie clip from the stage. The reason I do this is that there is no need to waste memory storing a movie clip that is invisible and no longer useful.


delete inputMC.onEnterFrame;

This line marks the final step towards ensuring our newly removed inputMC movie clip is not taking up system resources. I am deleting the onEnterFrame event handler that had so faithfully ensured that inputMC scaled proportionately while fading out at the same time.

Notice that I am using the delete keyword on inputMC.onEnterFrame. I am specifically deleting only this instance of the onEnterFrame event handler tethered to the inputMC movie clip. It is important to not arbitrarily delete the wrong onEnterFrame event handler.

Now that you have a good idea of what the code does, in the next page, I will provide an overview of how the various pieces of the program work together.

Onwards to the next page!

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.