Copy link to clipboard
Copied
right now I have a particle engine that creates snow falling. It uses the whole stage (_root). I'm trying to get snow to fall in a specific movie clip so it only attaches, and removes the snowflake (particle) in a selected movieclip. I have a MC called widescreen_mc and inside that I have sky_mc. I would like the snow to fall in the sky_mc so you only see the snow in the screen. I've tried attaching it in the sky MC and then change the other stettings (width height) to adjust, but nothing I do works as expected. Here is the Prticle engine code i've been using. can anyone show/tell me the changes I need to make to get it to work (brief explanation of any code changes would be apprciated so I can see my mistkes.)
Merry Christmas
import mx.transitions.Tween;
import mx.transitions.easing.*;
timer = 0;
timermax = 10;
particleCount = 0;
gravity = .01;
changeOver = 100;
checker = true;
percipitation = function()
{
//this._x += -5;
this.yspeed += gravity;
this._y += this.yspeed;
if (this._y > (Stage.height))
{
this.removeMovieClip();
}
}
onEnterFrame = function ()
{
timer ++;
if (timer == timermax)
{
//generate particle
particle = _root.attachMovie("Snow","P_"+ particleCount, _root.getNextHighestDepth());
///needs to set random position across
particle._x = Math.floor(Math.random()*(1+Stage.width+3)) -3;
//particle._x = _xmouse;
particle._y = -10;
particle.xspeed = random (6) - 3;
particle.yspeed = random (6) - 0;
particle.thesize = random (100) + 10;
particle.fade = Math.floor(Math.random()*(1+50-10))+10;
particle._xscale = particle._yscale = particle.thesize
particle._alpha = particle.fade
particle.onEnterFrame = percipitation;
timer =0;
particleCount ++;
//trace(particleCount);
clock_mc.swapDepths(particle);
change_mc.swapDepths(clock_mc);
winter_mc.swapDepths(change_mc);
protect_mc.swapDepths(winter_mc);
holder_mc.swapDepths(protect_mc);
}
//}
}
again, and then comment out those swapDepths() statements unless needed and change the _x,_y values of the particles so they start and stay (ie, edit precipitation) in your sky mc.
Copy link to clipboard
Copied
change this line:
particle = _root.attachMovie("Snow","P_"+ particleCount, _root.getNextHighestDepth());
to
particle = widescreen_mc.sky_mc.attachMovie("Snow","P_"+ particleCount, widescreen_mc.sky_mc.getNextHighestDepth());
and then comment out those swapDepths() statements unless needed and change the _x,_y values of the particles so they start and stay (ie, edit precipitation) in your sky mc.
Copy link to clipboard
Copied
Thanks Kglad
I had tried that, and the snowflakes are falling just as they did before, the entire stage, and not just in the widesceen movie clip?
they are being attached in the sky clip why would they be seen outside the wide
screen (the stage?)
I did put a trace for the size of the sky clip and the widescreen to see what the code was seeing for its height. they kept changing It shoud be static number
I'm more confused than I was before, Any suggestions on why its not working
Copy link to clipboard
Copied
again, and then comment out those swapDepths() statements unless needed and change the _x,_y values of the particles so they start and stay (ie, edit precipitation) in your sky mc.
Copy link to clipboard
Copied
Got it to work!
ThANKS!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now