Copy link to clipboard
Copied
Hello,
There are many action scripts out there for snow falling, custom made by various individuals. however this one in particular that I came across seems to have done the snow fall effect very nicely. The individual posted a video on Youtube showing the steps to make in order to generate this effect on Flash CS6. I took the same steps from the tutorial on my Adobe Animate CC 2017 yet I can never pull off the effect, as in nothing happens to the snowflake layer I create. Even after exporting the video to preview the movieclip's effect, nothing happens. I am still new to action scripts so its definitely my fault for not knowing what to do. I am wondering if someone here can guide me in their own words from start to finish while still using this script.
Link to the Youtube Tutorial:
https://www.youtube.com/watch?v=TpTeEPni05Y
Here is a copy of the script used in the Youtube video:
addEventListener (Event.ENTER_FRAME,snow);
function snow (event:Event):void {
var scale:Number=Math.random()*.6;
var _sf:snowflake=new snowflake();
_sf.x=Math.random()*640;
_sf.scaleX=scale;
_sf.scaleY=scale;
var speed:Number=Math.random()*2;
var RA:Array=new Array(-1,1);
var lf:int=RA[Math.round(Math.random())];
stage.addChild (_sf);
_sf.addEventListener (Event.ENTER_FRAME,snowfall);
function snowfall (event:Event):void {
_sf.y+=speed;
_sf.rotation+=Math.random()*20;
_sf.x+=(Math.random()*2)*lf;
}
}
never nest named functions and make sure you have a movieclip with class name snowflake. use:
addEventListener (Event.ENTER_FRAME,snow);
function snow (event:Event):void {
var scale:Number=Math.random()*.6;
var _sf:snowflake=new snowflake();
_sf.x=Math.random()*640;
_sf.scaleX=scale;
_sf.scaleY=scale;
_sf.lf=1-2*Math.round(Math.random());
_sf.speed =Math.random()*2;
stage.addChild (_sf);
_sf.addEventListener (Event.ENTER_FRAME,snowfall);
}
function snowfall (event:Event):void {
var _sf=event.cu
Copy link to clipboard
Copied
never nest named functions and make sure you have a movieclip with class name snowflake. use:
addEventListener (Event.ENTER_FRAME,snow);
function snow (event:Event):void {
var scale:Number=Math.random()*.6;
var _sf:snowflake=new snowflake();
_sf.x=Math.random()*640;
_sf.scaleX=scale;
_sf.scaleY=scale;
_sf.lf=1-2*Math.round(Math.random());
_sf.speed =Math.random()*2;
stage.addChild (_sf);
_sf.addEventListener (Event.ENTER_FRAME,snowfall);
}
function snowfall (event:Event):void {
var _sf=event.currentTarget;
_sf.y+=_sf.speed;
_sf.rotation+=Math.random()*20;
_sf.x+=(Math.random()*2)*_sf.lf;
if(_sf.y>stage.stageHeight+Math.max(_sf.width,_sf.height)){
_sf.removeEventListener(Event.ENTER_FRAME,snowfall);
stage.removeChild(_sf);
}
}
Copy link to clipboard
Copied
Thank you for updating this script, I will give it a try.
In addition, Merry Christmas and a happy New Years to everyone on these forums, and thanks for helping out*
Copy link to clipboard
Copied
you're welcome. don't forget to create a snowflake with that class.
Copy link to clipboard
Copied
Although I have never nested functions like that, the code you gave works without modifying at all. You may have not followed the creating of the movieclip symbol steps correctly. If you have followed the steps you should be able to delete the initial snowflake that you have on stage, it's not going to be controlled by the code anyway.
Copy link to clipboard
Copied
run it for a while and either your flash player or your computer will crash.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now