Hey guys,
I have a button that uses this code to rollover between 2 frames:
btn_splash.onRollOver = function()
{
btn_splash.gotoAndStop(2);
};
btn_splash.onRollOut = function()
{
btn_splash.gotoAndStop(1);
};
When I rollover the button, confetti is created using code. On the frame there is this code:
var mainJumping = true;//whether or not main is in the air
numConfetti = 20;
for (i=2; i<=numConfetti; i++) {
confetti1.duplicateMovieClip("confetti"+i, i+100);
}
This code is on the movieclip “confetti1”:
onClipEvent (load) {
function reset()
{
//generate the random color
R = random(256);
G = random(256);
B = random(256);
colorHexString = R.toString(16) + G.toString(16) + B.toString(16);
colorHex = parseInt(colorHexString, 16);
hairColor = new Color(this);
hairColor.setRGB(colorHex);
//generates random movemtn onscreen
xSpeed = random(3) + 1;
ySpeed = (Math.random() + 1) * random(5) + 1;
if (ySpeed == 1)
{
ySpeed = (Math.random() + 1) * random(5) + 1;
}
direction = random(2) + 1;
//randomly places confetti at the top of the screen
position = random(125) + 1;
_x = position;
_y = 0;
}
reset();
}
onClipEvent (enterFrame) {
//makes the confetti fall
_y += ySpeed;
directionChange = random(10) + 1;
if (directionChange == 1)
{
direction = random(2) + 1;
xSpeed = random(3) + 1;
}
if (direction == 1)
{
_x += xSpeed;
}
if (direction == 2)
{
_x -= xSpeed;
}
if (_y > 125)
{
reset();
}
if (_x < 0)
{
reset();
}
if (_x > 125)
{
reset();
}
}
My question is, when i rollout back to frame 1 how can i remove the confetti, or movieclips? Thanks