Hi everyone!
I’m trying to change a little a snow script that i’ve found on this website:
http://pixelfumes.blogspot.com/2006/11/actionscript-3-snow-storm-class.html
I’ve made everything work, the snow is falling.
But… i wanted to call those functions that are on the end of the comments:
// Call this function to stop the flakes from falling.
// You will need to specify which everyFrameEnd method to use (see below)
public function stopFlakes():void {
this.removeEventListener(Event.ENTER_FRAME, everyFrame);
this.addEventListener(Event.ENTER_FRAME, everyFrameEnd2);
}
//This function stops new flakes from falling, while the current flakes eventually dissapear off the bottom of the screen.
private function everyFrameEnd(e:Event):void{
this.y += speed;
this.x += drift;
if(this.y > viewHeight || this.x < 0 || this.x > viewWidth){
this.alpha = 0;
this.removeEventListener(Event.ENTER_FRAME, everyFrameEnd);
}
}
//This function fades all the flakes out (quicker than using above)
private function everyFrameEnd2(e:Event):void{
this.y += speed;
this.x += drift;
this.alpha -= .025;
if(this.y > viewHeight || this.x < 0 || this.x > viewWidth) {
this.removeEventListener(Event.ENTER_FRAME, everyFrameEnd2);
this.alpha = 0;
}
}
i’ve added them to my SnowFlake.as but… how do i call them and make them execute on the correct frame?
does anyone know a good tutorial that explains HOW i can call those functions properly?
thank you!