Hi there,
I’m working on a Christmas flash banner ad (wide sky - 160x600) (in CS5 using AS2), which features some snow that continually falls whilst the ad plays and loops twice.
I can easily get the snow to appear and fall, but my problem is that the snow always appears right in the very foreground and partially covers important elements that flash in and out whilst the ad plays. I want the snow to appear in the background of the ad (but not right at the very back - I want a couple of layers containing static images i.e. mountains behind the snow)[COLOR=#4b0082],[/COLOR] but must be behind other layers containing various text and images that will flash in and out whilst the ad plays.
I also want the snow to fall within a certain area of the ad, which is why I have stipulated 120 x 505 for the movie height/width in the AS2 code below.
In my library, I have a movie clip called “snow” that has an identifier of “snow_mc”.
I hope that’s enough information for you to work from - I am a complete novice when it comes to all of this so any help you can provide to solve this solution would be much appreciated.
Many thanks in advance.
/*** Snow Flakes Effect
*
* Version: 1.0
* Author: Philip Radvan
* URL: http://www.freeactionscript.com
*/
//settings
var speed:Number = 2;
var wind:Number = -1;
var movieWidth:Number = 120;
var movieHeight:Number = 505;
createSnow(_root, 100);
function createSnow(container:MovieClip, numberOfFlakes:Number):Void
{
//run a for loop based on numberOfFlakes
for (var i = 0; i < numberOfFlakes; i++)
{
//set temporary variable and attach snowflake to it from the library
var tempFlake:MovieClip = container.attachMovie("snow_mc", "snow"+container.getNextHighestDepth(), container.getNextHighestDepth());
//variables that will modify the falling snow
tempFlake.r = 1+Math.random()*speed;
tempFlake.k = -Math.PI+Math.random()*Math.PI;
tempFlake.rad = 0;
//giving each snowflake unique characteristics
var randomScale:Number = random(50)+50;
tempFlake._xscale = randomScale;
tempFlake._yscale = randomScale
tempFlake._alpha = random(100)+50;
tempFlake._x = random(movieWidth);
tempFlake._y = random(movieHeight);
//give the flake an onEnterFrame function to constantly update its properties
tempFlake.onEnterFrame = function()
{
//update flake position
this.rad += (this.k / 180) * Math.PI;
this._x -= Math.cos(this.rad)+wind;
this._y += speed;
//if flake out of bounds, move to other side of screen
if (this._y >= movieHeight) {
this._y = -5;
}
if (this._x >= movieWidth)
{
this._x = 1
}
if (this._x <= 0)
{
this._x = movieWidth - 1;
}
}
}
}
//buttons
//wind
left_btn.onRelease = function()
{
wind = 2;
}
none_btn.onRelease = function()
{
wind = 0;
}
right_btn.onRelease = function()
{
wind = -2;
}
//speed
slow_btn.onRelease = function()
{
speed = .5;
}
normal_btn.onRelease = function()
{
speed = 1
}
fast_btn.onRelease = function()
{
speed = 3
}