skerm
02-24-2006, 10:51 PM
HI, new to flash, new to actionscript and new to this forum so sorry for the noobishness ;)
I've been experimenting with actionscript and I have created a "window" on a layer and created another layer with a "snowing" actionscript, the idea being that the viewer is looking out from the inside of a house and it is snowing outside. My problem is that the snow animation doesn't care about layer ordering on the timeline and hence i get snow all over the place when i just want it to be "behind" the window frame so to speak.
I suspect it can have something to do with the _root thing but I really don't know. If someone could explain this to me I would be very grateful. Here is the code (from some tutorial).
var swidth = 550;
var sheight = 400;
// movieclip to hold our 'drops'
_root.createEmptyMovieClip("DropClip", 15999);
// setup the screen initially so it doesn't start empty
for(var i=0; i<50; i++)
{
createdrop(random(sheight));
}
// create our interval
var lightstorm = setInterval(createdrop, 100);
// our function which creates a rain/snow drop
function createdrop(y)
{
var clip = "drop" + Math.random();
_root.DropClip.attachMovie("Drop", clip, random(15999));
_root.DropClip[clip]._x = random(550);
if(y != null)
{
_root.DropClip[clip]._y = y;
}
_root.DropClip[clip]._alpha = random(100);
_root.DropClip[clip].speed = random(4);
_root.DropClip[clip].onEnterFrame = fall;
}
// our onEnterFrame function is what makes the drops
// move. we check if we can remove a clip if it's outside
// the stage, otherwise we increase the _y position
// of the drop.
function fall()
{
if(this._y < sheight)
{
this._y += 1 + this.speed;
}
else
{
delete this.onEnterFrame;
this.removeMovieClip();
}
}
And there is a movieclip called Drop (just a small circle) in my library. Any ideas on how to make the "snow" appear behind another layer so that it doesnt cover the entire movie screen?
Thanks
/skerm
I've been experimenting with actionscript and I have created a "window" on a layer and created another layer with a "snowing" actionscript, the idea being that the viewer is looking out from the inside of a house and it is snowing outside. My problem is that the snow animation doesn't care about layer ordering on the timeline and hence i get snow all over the place when i just want it to be "behind" the window frame so to speak.
I suspect it can have something to do with the _root thing but I really don't know. If someone could explain this to me I would be very grateful. Here is the code (from some tutorial).
var swidth = 550;
var sheight = 400;
// movieclip to hold our 'drops'
_root.createEmptyMovieClip("DropClip", 15999);
// setup the screen initially so it doesn't start empty
for(var i=0; i<50; i++)
{
createdrop(random(sheight));
}
// create our interval
var lightstorm = setInterval(createdrop, 100);
// our function which creates a rain/snow drop
function createdrop(y)
{
var clip = "drop" + Math.random();
_root.DropClip.attachMovie("Drop", clip, random(15999));
_root.DropClip[clip]._x = random(550);
if(y != null)
{
_root.DropClip[clip]._y = y;
}
_root.DropClip[clip]._alpha = random(100);
_root.DropClip[clip].speed = random(4);
_root.DropClip[clip].onEnterFrame = fall;
}
// our onEnterFrame function is what makes the drops
// move. we check if we can remove a clip if it's outside
// the stage, otherwise we increase the _y position
// of the drop.
function fall()
{
if(this._y < sheight)
{
this._y += 1 + this.speed;
}
else
{
delete this.onEnterFrame;
this.removeMovieClip();
}
}
And there is a movieclip called Drop (just a small circle) in my library. Any ideas on how to make the "snow" appear behind another layer so that it doesnt cover the entire movie screen?
Thanks
/skerm