Flint Particle System Forum - createPixelParticlesFromBitmapData 2010-11-24T23:35:04+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher createPixelParticlesFromBitmapData http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=879#Comment_879 2009-07-31T20:37:37+01:00 2009-07-31T20:43:09+01:00 kairos http://flintparticles.org/forum/account.php?u=232 First of all many thanks for the great job done! I'm working with flint for the past weeks and I'm surprising with some nice features such as the transformation of a bitmap into ...
However, I can't use "createPixelParticlesFromBitmapData", always receive this error:

-----
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at org.flintparticles.twoD.renderers::DisplayObjectRenderer/addParticle()
at org.flintparticles.common.renderers::SpriteRendererBase/addEmitter()
at party_fla::MainTimeline/frame1()

------

The exact code is this:]]>
createPixelParticlesFromBitmapData http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=880#Comment_880 2009-07-31T20:40:34+01:00 2009-07-31T20:42:53+01:00 kairos http://flintparticles.org/forum/account.php?u=232 var c:BitmapData=new BitmapData(ximage,yimage,true,0); c.draw(mc); // ERROR!!! //particles=Particle2DUtils.createPixelParticlesFromBitmapData(c,emitter.particleFactory,0,0); // ...
var c:BitmapData=new BitmapData(ximage,yimage,true,0);
c.draw(mc);

// ERROR!!!
//particles=Particle2DUtils.createPixelParticlesFromBitmapData(c,emitter.particleFactory,0,0);

// ALLRIGHT!!
particles=Particle2DUtils.createRectangleParticlesFromBitmapData(c,4,emitter.particleFactory,40,40);

firsttime();

function firsttime():void {
if (firsttim) {
particles_original=CloneParticleArray(particles);
firsttim=false;
}
}
emitter.addExistingParticles( particles, false );
renderer.addEmitter( emitter );
addChild( renderer );
stage.addEventListener( MouseEvent.MOUSE_UP, action );

var xa:Number=-200;
var ya:Number=yimage/2;
var moving = new Move ();
var explode=new Explosion(8,xa,ya,500);
function action( ev:MouseEvent ):void {
if (out) {
emitter.start();
emitter.addAction(explode);
emitter.addAction(moving);
out=false;
} else {
out=true;
emitter.removeAction(explode);
emitter.removeAction(moving);

for (var i:uint = 0; i<emitter.particles.length; i++) {
TweenLite.to((emitter.particles[i]),1, {x:particles_original[i].x, y:particles_original[i].y} );
}
}
}
function CloneParticleArray(source:Object):* {
copy = new ByteArray();
copy.writeObject(source);
copy.position=0;
return (copy.readObject());
}
]]>
createPixelParticlesFromBitmapData http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=892#Comment_892 2009-08-08T11:16:11+01:00 2010-11-24T23:35:04+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi You can only use pixel particles with a PixelRenderer. You're trying to use them with a DisplayObjectRenderer. Richard
You can only use pixel particles with a PixelRenderer. You're trying to use them with a DisplayObjectRenderer.

Richard]]>