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

Cant figure out how to stop it snowing... please help :(

New Here ,
Nov 16, 2014 Nov 16, 2014

Copy link to clipboard

Copied

Heya, new ish with flash and actionscript, learning at college and im enjoying it so much im rushing ahead and doing my own thing... thought i would be clever and create a snow effect, alas i cant get it to stop when i want to to, tried all sorts of stop; stopall; commands but its not happening...

Thanks either way for any help

Heres the code im using...

addEventListener (Event.ENTER_FRAME,snow);

function snow (event:Event):void {

   

    var scale:Number=Math.random()*.6;

    var _sf:Snowflake1=new Snowflake1();

    _sf.x=Math.random()*1024;

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

    }

}

Thanks again either way

TOPICS
ActionScript

Views

469

Translate

Translate

Report

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 ,
Nov 16, 2014 Nov 16, 2014

Copy link to clipboard

Copied

If you remove the first event listener it will stop creating snow.

Votes

Translate

Translate

Report

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
New Here ,
Nov 16, 2014 Nov 16, 2014

Copy link to clipboard

Copied

Thanks for your time, just tried it inside and outside a keyframe later on in frame 970, returns with the message

Scene 2, Layer 'Snow', Frame 1540, Line 11021: Duplicate function definition.

Renamed the function snow and snowfall, left in the snow function and deleted everything else

function snowstop (event:Event):void {

}

Is all im left with now, its still snowing 😕

Thankyou

Votes

Translate

Translate

Report

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
Enthusiast ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

As Ned sad, removing the frame listener that calls snow will stop the flake creation. You should also add a test to snowFall so that when y exceeds the stage height the flake will be removed.

Votes

Translate

Translate

Report

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 ,
Nov 17, 2014 Nov 17, 2014

Copy link to clipboard

Copied

LATEST

If that is all you have then it will do nothing to stop the snow.  When you added the event listener you used...

      addEventListener (Event.ENTER_FRAME,snow);

so to remove that event listener you use...

      removeEventListener (Event.ENTER_FRAME,snow);

Votes

Translate

Translate

Report

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