A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Problems masking actionscripted snow

Hybrid View

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    8

    Problems masking actionscripted snow

    Briefly, I need to create a snow globe, so that when you click a button the globe shakes and snow falls.
    The globe is created, the animation is no problem, Ive got the coding for the snow, how ever I cannot mask the snow to fall within the globe, it covers the whole screen.

    Any solutions?

    The code attached to the snowflake movie clip:

    onClipEvent (load) {
    //specifies the size of the movie stage
    movieWidth = 1024;
    movieHeight = 768;

    //variables that will modify the falling snow
    i = 1+Math.random()*2;
    k = -Math.PI+Math.random()*Math.PI;

    //giving each snowflake unique characteristics
    this._xscale = this._yscale=50+Math.random()*100;
    this._alpha = 75+Math.random()*100;
    this._x = -10+Math.random()*movieWidth;
    this._y = -10+Math.random()*movieHeight;
    }
    onClipEvent (enterFrame) {
    //putting it all together
    rad += (k/180)*Math.PI;
    this._x -= Math.cos(rad);
    this._y += i;
    if (this._y>=movieHeight) {
    this._y = -5;
    }
    if ((this._x>=movieWidth) || (this._x<=0)) {
    this._x = -10+Math.random()*movieWidth;
    this._y = -5;
    }
    }


    The code attached in the actions layer frame on the stage:

    for (k=0; k<1000; k++) {
    duplicateMovieClip(this.snow, "snow"+k, k);
    }

  2. #2
    Member
    Join Date
    Nov 2009
    Location
    Philadelphia
    Posts
    40
    i've attached an example of what you can do... in the future please wrap your code in the php tags.
    PHP Code:
    //my code wrapped in php tags... 
    i've nested your code in a "holder" movieclip and manually masked the holder movieclip.
    Attached Files Attached Files
    - Nick Stanziani

    pls support: www.whowantsacookie.com

    My site: pebcak

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    8
    Sorry for not wrapping it in tags.
    Thank you for that, exactly the solution I needed.
    Just for my knowledge, any reason why the normal mask would not work when I tried it? The only way I could mask it normally was to put the snow in an external swf, import it in and mask that instead.

  4. #4
    Junior Member
    Join Date
    Oct 2009
    Posts
    8
    I have hit another problem now, how do I get the mask to fade so the snow disappears altogether.
    I have tried fading the mcMask out via colour>alpha, ive tried adding cacheAsBitmap (dont know if I wrote the code correct but it did not work anyway) also tried fading the alpha out on the drawing object.

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    if it's a dynamic mask, fading it would make it disappear thus un-masking the snow.
    To actually fade the snow you have to alpha out the snowflake movie clip. The easiest way to do so would be for you to send that flake timeline to a fade out animation.

    gparis

  6. #6
    Junior Member
    Join Date
    Oct 2009
    Posts
    8
    Cheers for that!

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