the code i used to make a snowfalling scene
took me about 4-5 hours to figure it out but meh.
stage.addEventListener(Event.ENTER_FRAME, snowflake);
function snowflake (event : Event ) : void// function to create snowflakes
{
var _Snowflake:mcSnowflake;
_Snowflake = new mcSnowflake();
addChild(_Snowflake);
_Snowflake.x = -350 + Math.random() * 900;// placement of snowflake
_Snowflake.y = Math.random() * 40;//placement of snowflake
_Snowflake.scaleX =_Snowflake.scaleY = Math.random();//size of snowflake random
_Snowflake.alpha = Math.random() * 1 ;//transparency of snowlake random
stage.addEventListener(Event.ENTER_FRAME, snowfall);
function snowfall(event:Event):void
{
if ( _Snowflake.y> 400 || _Snowflake.x> 550)//to keep em moving just off the stage
{ stage.removeEventListener(Event.ENTER_FRAME, snowfall);
removeChild(_Snowflake);
}
else
{ _Snowflake.y += 5; _Snowflake.x += Math.random() * 10; }
}
}
Tuesday, September 30, 2008
Subscribe to:
Post Comments (Atom)
1 comment:
I forgot...mcSnowflake is the name of the snowflake I made and saved as a movie clip. use this as to what the particle will be, or it will call the wrong item :o
Post a Comment