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