Flint Particle System Forum - Use a class file with ImageClasses to generate particles? 2010-11-24T23:18:28+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher Use a class file with ImageClasses to generate particles? http://flintparticles.org/forum/comments.php?DiscussionID=264&Focus=941#Comment_941 2009-10-20T20:37:15+01:00 2009-10-20T21:01:05+01:00 ed http://flintparticles.org/forum/account.php?u=257 I've learned from the tutorial that the emitters must create the particles to be rendered using either the DisplayObjectRenderer or BitmapRenderer. But I haven't seen an example much discussion about ...
I'm trying to use ImageClasses to "load" an array of MovieClips.


//PHP loaded, XML nodes converted to object properties...

private function dataLoaded(e:DataEvent):void {
_itemArray = e.items;

for (var i:uint = 0; i < _itemArray.length; i++) {
var box:Box = new Box(_itemArray[i].sentence.length);
_boxArray.push(box);
}

images = new ImageClasses(_boxArray);
emitter.counter = new Blast(_boxArray.length);
emitter.addInitializer(images);
emitter.addInitializer(new Position(zone));

renderer.addEmitter(emitter);
renderer.mouseChildren = true;
addChild(renderer);
}

But I keep getting this error:

Error #1034: Type Coercion failed: cannot convert Box@35537451 to Class.

I've compared my code to the snippet seen here: http://flintparticles.org/forum/comments.php?DiscussionID=242&page=1 but I still get the error...any ideas?]]>
Use a class file with ImageClasses to generate particles? http://flintparticles.org/forum/comments.php?DiscussionID=264&Focus=942#Comment_942 2009-10-20T22:50:51+01:00 2009-10-20T22:55:04+01:00 ed http://flintparticles.org/forum/account.php?u=257 Solution found :) Took a hint from this post: http://flintparticles.org/forum/comments.php?DiscussionID=155. I placed the particle first, then added them to the emitter...I'm guessing I could have ... Took a hint from this post: http://flintparticles.org/forum/comments.php?DiscussionID=155. I placed the particle first, then added them to the emitter...I'm guessing I could have placed the particles after adding them as well, but this seemed the most straightforward to me.


private function dataLoaded(e:DataEvent):void {
_itemArray = e.items;

for (var i in _itemArray) {
var l:uint = _itemArray[i].sentence.length;
var box:Box = new Box(l);
box.x = 900 * Math.random() + 50;
box.y = 550 * Math.random() + 25;
addChild(box);

box.setData(_itemArray[i]);
_boxArray.push(box);

var particle = Particle2DUtils.createParticle2DFromDisplayObject(box, renderer, emitter.particleFactory);
emitter.addExistingParticles([particle], true);
}

emitter.addInitializer(new Position(zone));

emitter.addAction(new MutualGravity(5, 500, 3));
emitter.addAction(new TurnTowardsMouse(.25, renderer));
emitter.addAction(new BoundingBox(0, 0, 1000, 600));
emitter.addAction(new SpeedLimit(150));
emitter.addAction(new Move());

renderer.addEmitter(emitter);
renderer.mouseChildren = true;
addChild(renderer);

emitter.start();
emitter.runAhead(10);
}


BTW, Richard, thank you for this remarkable system. You've really made particle simulation accessible to everyone. Amazing documentation as well. Hats off to you!]]>
Use a class file with ImageClasses to generate particles? http://flintparticles.org/forum/comments.php?DiscussionID=264&Focus=950#Comment_950 2009-11-02T08:01:05+00:00 2010-11-24T23:18:28+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Hi Ed I'm pleased you found the solution. It is possible to pass the image directly to the particle - particle.image = box but because the emitter works with behaviours, you'd have to wrap ...
I'm pleased you found the solution. It is possible to pass the image directly to the particle -

particle.image = box

but because the emitter works with behaviours, you'd have to wrap this up as an Initializer.

I intend to add a tutorial about writing custom Initializers and Actions soon, but there's a few bits of work I have to get out the way first.

Richard]]>