Hello everybody, A quick and probably stupid question. Im very very new at AS,
I am using this AS code for a snow effect in a banner… works great!
But, I would like to know how to turn it on and off, and reset it before it loops in the banner. . I have no clue! Tried a few things, but at best I can only stop it.
Any help would be greatly appreciated!!!
Here is the code…
// SNOWSTORM IN 15 MINS!
// Author : Seb Lee-Delisle
// Blog : www.sebleedelisle.com
// Company : www.pluginmedia.net
//
// This work is licensed under a Creative Commons 2.0 License.
// Full details at
// http://creativecommons.org/licenses/by/2.0/uk/
// You may re-use this code as you wish, but a credit would be
// appreciated. And I’d love to see what you do with it!
// mail me : seb@sebleedelisle.com
import flash.events.Event;
import flash.geom.Rectangle;
// first make an array to put all our snowflakes in
var snowFlakes : Array = new Array();
// and decide the maxium number of flakes we want
var numFlakes : uint = 500;
// and define a rectangle to store the screen dimensions in.
var screenArea:Rectangle = new Rectangle(0,0,486,60);
// start listening for an ENTER_FRAME event (the equivalent
// of the AS2 onEnterFrame function)
addEventListener(Event.ENTER_FRAME, frameLoop);
// and define the function that is called on an ENTER_FRAME event
function frameLoop(e:Event)
{
var snowflake : SnowFlake;
// if we don't have the maximum number of flakes...
if(snowFlakes.length<numFlakes)
{
// then make a new one!
snowflake = new SnowFlake(screenArea);
// add it to the array of snowflakes
snowFlakes.push(snowflake);
// and add it to the stage
addChild(snowflake);
}
// now calculate the wind factor by looking at the x position
// of the mouse relative to the centre of the screen
var wind : Number = ((screenArea.width/2) - mouseX);
// and divide by 60 to make it smaller
wind /=60;
// now loop through every snowflake
for(var i:uint = 0; i<snowFlakes.length; i++)
{
snowflake = snowFlakes*;
// and update it
snowflake.update(wind);
}
}
Thank you very much in advance!!!
Coz