Flint Particle System Forum - overriding DisplayObjectRenderer 2011-12-10T23:45:03+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher overriding DisplayObjectRenderer http://flintparticles.org/forum/comments.php?DiscussionID=451&Focus=1528#Comment_1528 2011-01-27T17:18:12+00:00 2011-01-27T17:18:42+00:00 FlashDev2007 http://flintparticles.org/forum/account.php?u=460 Recently I needed to eject particles from a bottle and have them go behind a logo and then fall back in front of it. I decided to extend the renderer to handle the children on the display list. ...
I made a small donation, cheers to you Richard...


package
{
import flash.display.DisplayObject;
import flash.geom.ColorTransform;

import org.flintparticles.twoD.particles.Particle2D;
import org.flintparticles.twoD.renderers.DisplayObjectRenderer;

public class MultipleDisplayObjectRenderer extends DisplayObjectRenderer
{
protected var image:DisplayObject;

public function MultipleDisplayObjectRenderer()
{
super();
}

public function addImage(img:DisplayObject):void
{
image = img;
addChild(image);
}

override protected function renderParticles( particles:Array ):void
{
var particle:Particle2D;
var img:DisplayObject;
var len:int = particles.length;

for( var i:int = 0; i < len; ++i )
{
particle = particles[i];
img = particle.image;
img.transform.colorTransform = particle.colorTransform;
img.transform.matrix = particle.matrixTransform;

// if the particle is at half life, and its index is lower than the image swap em over
if(particle.age > particle.lifetime * 0.5 && getChildIndex(img) < getChildIndex(image))
{
swapChildren(image, img);
}
}
}
}
}
]]>
overriding DisplayObjectRenderer http://flintparticles.org/forum/comments.php?DiscussionID=451&Focus=1535#Comment_1535 2011-02-03T08:03:30+00:00 2011-12-10T23:45:03+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Thank you. I've been asked about this before - now here's some code I can point users to.