I am trying to create a fade effect. When I click on a movie clip, I want the others to gradually fade from _alpha =100 to _alpha = 25. The way I have it now it will instantly take the clip from 100 to 25.
This is on the movie clip that I click
[AS]
on(release){
this.gotoAndStop(2);
_root.disappear();
}[/AS]
This is the function definition on the root:
[AS]
function disappear(){
for(var i = 100; i > 25; i–){
for loops do the process then show the final result. You would need to use an event handler (onEnterFrame in this case) to gradually fade your clip…
[AS]function disappear(){
//call onEnterFrame dynamic event handler
_root[“clip1”].onEnterFrame = function(){
//decrement alpha by 5
this._alpha -= 5
//if the alpha is less than or equal to 25
if (this._alpha <= 25){
//set the alpha to 25
this._alpha = 25
//delete the onEnterFrame to stop decrementing the alpha
delete this.onEnterFrame
}
}
its nothing with arrays, just that if there is a variable, and you want to target the mc with the instance name of the value of the variable, or something similar, you use _root[variable] or _root[“movieclip”+i]
kartik: It is something with arrays. It is called associative array referencing. All the items in a timeline are stored in an array, and you can target that timelines array to get the clip/variable you want in the method you showed.