Alpha fade in using actionscript

Hi I am trying to fade in an image using actionscript,

this is the code i have,

speed = 10;
image.onEnterFrame = function(){
this._alpha>=100 ? this._alpha-=speed : delete this.onEnterFrame;
}

I’ve set the image on stage to alpha 0, i run this movie but nothing seems to happen, i’ve given the movie clip name an instance name of image.

can someone help?

try this:


var speed = 10;
image.onEnterFrame = function() {
(this._alpha<=100) ? this._alpha+=speed : delete this.onEnterFrame;
}

hey… I’ve seen that so often, but never known the name of that conditional statement… what’s it called?

Mee tooo! I need to know this one as well!

well, go right to the source.
anyways its the same as going:


var speed = 10;
image.onEnterFrame = function() {
if(this._alpha<=100) {
this._alpha+=speed 
} else { 
delete this.onEnterFrame;
}
}

It is called a tertiary operator…

http://www.kirupa.com/developer/actionscript/tricks/tertiary.htm

oh thanks… I never read to the bottom of that page the last time I saw it :lol:

:stuck_out_tongue: