A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Help with Snow and Actionscript

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    4

    Help with Snow and Actionscript

    Hi, I have to create a winter scene in flash, I have created a moving background upon which a character will be added I have also created snow using a script I found online.
    Everything works fine apart from when the scene moves back to the first keyframe when it loops for the background, the snow stops and starts again, is there a solution to just keep that running at all times??

    Thanks

  2. #2
    Senior Member
    Join Date
    Jun 2008
    Posts
    549
    It would be easier to understand if you upload your code.

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    4
    Sure heres the code:


    Code:
        init = function () {
    
        width = 340;
        // pixels
        height = 220;
        // pixels
        max_snowsize =3;
        // pixels
        snowflakes = 100;
        // quantity
        for (i=0; i<snowflakes; i++) {
    
        t = attachMovie("snow", "snow"+i, i);
        t._alpha = 20+Math.random()*60;
        t._x = -(width/2)+Math.random()*(1.5*width);
        t._y = -(height/2)+Math.random()*(1.5*height);
        t._xscale = t._yscale=50+Math.random()*(max_snowsize*10);
        t.k = 1+Math.random()*2;
        t.wind = -1.5+Math.random()*(1.4*3);
        t.onEnterFrame = mover;
    
        }
    
        };
        mover = function() {
    
        this._y += this.k;
        this._x += this.wind;
        if (this._y>height+10) {
    
        this._y = -20;
    
        }
        if (this._x>width+20) {
    
        this._x = -(width/2)+Math.random()*(1.5*width);
        this._y = -20;
    
        } else if (this._x<-20) {
    
        this._x = -(width/2)+Math.random()*(1.5*width);
        this._y = -20;
    
    
    
        }
    
        }
        init();

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    go back to frame2 instead of frame1.

    gparis

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    4
    Wouldn't that mess up the animation for the moving background, not make it seamless?

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    move the whole animation 1 frame so you can go back to frame2 instead of 1.
    Keyframe1 obviously has the duplication via attachMovie, therefore resets the initialisation. You can't go back to that frame.

    gparis

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    4
    Thanks for your help works perfectly

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