Flint Particle System Forum - createPixelParticlesFromBitmapData Sun, 26 Dec 2010 18:22:15 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher createPixelParticlesFromBitmapData http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=879#Comment_879 http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=879#Comment_879 Fri, 31 Jul 2009 20:37:37 +0100 kairos
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 http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=880#Comment_880 Fri, 31 Jul 2009 20:40:34 +0100 kairos
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 http://flintparticles.org/forum/comments.php?DiscussionID=247&Focus=892#Comment_892 Sat, 08 Aug 2009 11:16:11 +0100 Richard
You can only use pixel particles with a PixelRenderer. You're trying to use them with a DisplayObjectRenderer.

Richard ]]>