# Remove particle after

**URL:** <https://forum.kirupa.com/t/remove-particle-after/284477>\
**Category:** Uncategorized\
**Created:** [March 19, 2009, 2:51pm UTC](https://forum.kirupa.com/t/remove-particle-after/284477 "2009-03-19T14:51:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loyen\_](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Loyen\_](https://forum.kirupa.com/u/Loyen_)\
**Post date:** [March 19, 2009, 2:51pm UTC](https://forum.kirupa.com/t/remove-particle-after/284477/1 "2009-03-19T14:51:02Z")

</div>

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.

```auto
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
