Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Snow Falling Action Script Tweaking

Explorer ,
Dec 23, 2017 Dec 23, 2017

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;
}
}

3.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 23, 2017 Dec 23, 2017

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

...
Translate
Community Expert ,
Dec 23, 2017 Dec 23, 2017

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);

}
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 24, 2017 Dec 24, 2017

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*

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2017 Dec 25, 2017
LATEST

you're welcome.  don't forget to create a snowflake with that class.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 24, 2017 Dec 24, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2017 Dec 24, 2017

run it for a while and either your flash player or your computer will crash. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines