A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: So confused! (Flash n00b)

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    2

    So confused! (Flash n00b)

    Hi Everyone!

    I am trying to figure something out for work and don't know anything about actionscripting

    I found some code for falling snow which I have inserted into a keyframe. It works wonderfully but I need it to stop partway through my timeline.

    I have tried making it into it's own movie and adding the movie to the keyframe instead of the code but it doesn't work.

    Is there an action I can insert along my timeline that will stop the previous action but continue playing my timeline?

    Thanks so much for any advice!

    This is the code I used:

    /**
    * Snow Flakes Effect
    *
    * Version: 1.0
    * Author: Philip Radvan
    * URL: http://www.freeactionscript.com
    */

    //settings
    var speed:Number = 3;
    var wind:Number = 2;
    var movieWidth:Number = 728;
    var movieHeight:Number = 90;

    createSnow(_root, 600);


    function createSnow(container:MovieClip, numberOfFlakes:Number):Void
    {
    //run a for loop based on numberOfFlakes
    for (var i = 0; i < numberOfFlakes; i++)
    {
    //set temporary variable and attach snowflake to it from the library
    var tempFlake:MovieClip = container.attachMovie("snow_mc", "snow"+container.getNextHighestDepth(), container.getNextHighestDepth());

    //variables that will modify the falling snow
    tempFlake.r = 1+Math.random()*speed;
    tempFlake.k = -Math.PI+Math.random()*Math.PI;
    tempFlake.rad = 0;

    //giving each snowflake unique characteristics
    var randomScale:Number = random(50)+50;
    tempFlake._xscale = randomScale;
    tempFlake._yscale = randomScale
    tempFlake._alpha = random(100)+50;
    tempFlake._x = random(movieWidth);
    tempFlake._y = random(movieHeight);

    //give the flake an onEnterFrame function to constantly update its properties
    tempFlake.onEnterFrame = function()
    {
    //update flake position
    this.rad += (this.k / 180) * Math.PI;
    this._x -= Math.cos(this.rad)+wind;
    this._y += speed;

    //if flake out of bounds, move to other side of screen
    if (this._y >= movieHeight) {
    this._y = -5;
    }
    if (this._x >= movieWidth)
    {
    this._x = 1
    }
    if (this._x <= 0)
    {
    this._x = movieWidth - 1;
    }
    }
    }
    }

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    you need to change createSnow(_root, 600); to createSnow(yourMovieClip, 600); so that you could remove yourMovieClip later.
    who is this? a word of friendly advice: FFS stop using AS2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center