Wednesday, January 23, 2008

fade

onClipEvent(load) {
this._alpha = 0;
this.dir = -1;
this.speed = 10; // the value used to modify the speed of the fade
}
onClipEvent(enterFrame) {
if (this._alpha <= 0) {
this._alpha = 0; // if the alpha value had gone negative, reset it to zero
this.dir *= -1;
}
if (this._alpha >= 100) {
this._alpha = 100; // similarly if it had exceeded 100 reset it to 100
this.dir *= 0;
}
this._alpha += this.speed * this.dir;
}

Labels: , , ,

0 Comments:

Post a Comment