View Full Version : gradual alpha fade
rolando.lopez
August 5th, 2003, 04:30 PM
Hi,
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
on(release){
this.gotoAndStop(2);
_root.disappear();
}
This is the function definition on the root:
function disappear(){
for(var i = 100; i > 25; i--){
_root["clip1"]._alpha = i;
}
}
Can you guys help me out?
Thanks
lostinbeta
August 5th, 2003, 04:46 PM
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..
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
}
}
}
jeremy*
August 6th, 2003, 02:00 AM
can you explain the significance of calling
_root["clip1"].onEnterFrame
instead of just calling
clip1.onEnterFrame
or
_root.clip1.onEnterFrame.
does it have to do with arrays?
lostinbeta
August 6th, 2003, 02:19 AM
In this case there is no difference, just personal preference.
radicaljugnu
August 6th, 2003, 06:24 AM
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]
rolando.lopez
August 6th, 2003, 08:38 AM
Lostinbeta,
thanks. That worked great!
lostinbeta
August 6th, 2003, 01:23 PM
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.
rolando: Cool :thumb:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.