|
Added
Flexibility: Using SmartClips
There is a fundamental problem with the ScriptClip in its current form.
Examine the code again:
_parent._alpha+=5;
Recall that
we want to make scripts as generic as possible, so we have the flexibility
to use them throughout the movie. Our script has made the target Instance
that the script affects generic, but the value of the increment in this
case is fixed, currently at 5. What if we want another Instance to fade
in to view gradually, with a value of say 3? Wed would have to make
another ScriptClip with a different value. This could add up to a number
of ScriptClips based on the value of the increment, which is no more efficient
than simply including the script in various key frames throughout the
movie.
What if we could make the value generic as well? For example, Im
going to change the script from:
_parent._alpha+=5;
to
_parent._alpha+=userValue;
Ive
changed the fixed value (5) into a variable, userValue. By making the
ScriptClip into a SmartClip, we can specify the value of the variable
userValue each time we use an Instance of the script.alphaFadeIn Symbol.
SmartClips allow us to control variables within ActionScript inside of
Symbols.
|