To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 11-25-2009, 10:41 AM   #1
james_dean1986
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);
}
james_dean1986 is offline   Reply With Quote
Old 11-25-2009, 01:18 PM   #2
nstanziani
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
File Type: fla snowGlobe.fla (27.0 KB, 18 views)
__________________
- Nick Stanziani

pls support: www.whowantsacookie.com

My site: pebcak
nstanziani is offline   Reply With Quote
Old 11-26-2009, 04:08 AM   #3
james_dean1986
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.
james_dean1986 is offline   Reply With Quote
Old 11-26-2009, 08:13 AM   #4
james_dean1986
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.
james_dean1986 is offline   Reply With Quote
Old 11-26-2009, 08:31 AM   #5
gparis
Super Moderator
 
Join Date: Aug 2000
Location: Montréal
Posts: 13,432
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
__________________


AS 2.0 Forum Guidelines || Use AS tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4)
gparis is offline   Reply With Quote
Old 11-26-2009, 08:45 AM   #6
james_dean1986
Junior Member
 
Join Date: Oct 2009
Posts: 8
Cheers for that!
james_dean1986 is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:43 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.