keep the frame rate to 10fps. Draw the shape and convert it to a movie clip symbol with instance name “shape”. Now add a keyframe at frame 2 and one at frame 3. In the actions of frame one, add-
time=5
i=0
in frame 2 add-
*Originally posted by wilma *
**using AS, on loading a movie a solid shape is there with alpha at 100% then over a period of 5 secs its alpha is reduced to 0.
i’m new to this…please help if you want to if you don’t have a good weekend but think of me struggling onwards and upwards… **
If you are using Flash MX you can use dynamic event handlers to slowly fade the clip.
That line right there decreases the current alpha setting by 5. So if your clip alpha is 100, it will then be 95, then 90, then 85, etc, etc.
To increase the alpha just change -= to +=.
Now my question is this… are you trying to fade in and out successively? or are you just trying to fade a clip in and that is it?
Considering you just asked for fading in I won’t go the extra mile of in and out unless you need that.
[AS]
//start clips alpha setting at 0
clipInstanceName._alpha = 0;
//initiate clips onEnterFrame handler
clipInstanceName.onEnterFrame = function(){
//keep increasing the alpha by 5
this._alpha += 5;
//if the alpha setting is greater or equal to 100
if (this._alpha >= 100){
//keep it there
this._alpha = 100;
//and stop running the onEnterFrame
delete this.onEnterFrame;
}
}[/AS]
lostinbeta, thanks for your help on that. since you asked, yeh it would be good to get it to fade in and out successively… it would be great if you could show me that.
Ok, to get it to work in and out like that you have to use a variable to hold a true or false value, we will call this variable “trigger”
[AS]
//start trigger at false
var trigger = false;
//start clips alpha setting at 0
clipInstanceName._alpha = 0;
//initiate clips onEnterFrame handler
clipInstanceName.onEnterFrame = function(){
//if trigger is false
if (!trigger){
//keep increasing the alpha by 5
this._alpha += 5;
//if the alpha setting is greater or equal to 100
if (this._alpha >= 100){
//set alpha to 100
this._alpha = 100;
//set trigger to true
trigger = true;
}
//else if trigger is true
} else {
//keep decreasing the alpha by 5
this._alpha -= 5;
//if the alpha setting is less than or equal to 0
if (this._alpha <= 0){
//set alpha to 0
this._alpha = 0;
//set trigger to false
trigger = false;
//trigger = false will make it fade back in
//to just stop it now change trigger=false to delete this.onEnterFrame
}
Kax, if you’ve got the time or the inclination to explain that code it would be most appreciated, if not no worries. but why, apart from the fact its a more consice piece of code, use yours as opposed to lostinbeta’s code??