Hello fellas of kirupa!
I got a problem with particles, I’m making an effect that squares goes up and fades out from the mouse (like squarly smoke) and it looks fine, but I got two problems:
[LIST=1]
[]The boxes should fade out, but sometimes they get stuck in the background while fading, and I have no idea why.
[]I want the particles to get removed once they’ve fade out, how should I do this?
[/LIST]
In order to make the following code work, you need to have created and linked a movie clip called Square (notice the big S) into AS3.
import fl.transitions.*;
import fl.transitions.easing.*;
// Creates an array to hold the tweens so they don't get garbage collected and creates a tween varaible
var tweensArray:Array = new Array();
var tweensresize:Tween;
stage.addEventListener(Event.ENTER_FRAME, eventHandler);
function eventHandler(e:Event):void {
var square:Square = new Square();
square.x = mouseX + Math.floor(Math.random()*10-2);
tweensresize = new Tween(square
,"y"
,Regular.easeOut
,mouseY - 2, mouseY - 60,
1, true );
tweensresize = new Tween(square,
"alpha",
Regular.easeOut,
1, 0,
1, true );
addChild(square);
trace(particles);
pText.text = particles;
}
Thanks for reading and help is appreciated. :3