Welcome, Guest
Want to take part in these discussions? Sign in if you have an account, or apply for one below
-
- CommentAuthorkairos
- CommentTimeJul 31st 2009 edited
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 particles.
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: -
- CommentAuthorkairos
- CommentTimeJul 31st 2009 edited
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());
} -
- CommentAuthorRichard
- CommentTimeAug 8th 2009
Hi
You can only use pixel particles with a PixelRenderer. You're trying to use them with a DisplayObjectRenderer.
Richard
1 to 3 of 3
