Flint Particle System Forum - InitializerGroup question 2011-12-13T13:35:58+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & Feed Publisher InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1650#Comment_1650 2011-06-10T23:41:53+01:00 2011-12-13T13:35:58+00:00 fred http://flintparticles.org/forum/account.php?u=510 Hello, I am trying to display 2 shapes from the library using InitializerGroup. I can only see 1 at the time... don't know what I am doing wrong :( var AppleInitializer:InitializerGroup = new ...
var AppleInitializer:InitializerGroup = new InitializerGroup();
AppleInitializer.addInitializer( new SharedImage( new Apple()));
AppleInitializer.addInitializer( new ScaleImageInit(0.1, 0.3));
AppleInitializer.addInitializer( new Position( new RectangleZone( 0, 0, 1000, 500)));

var MickeyInitializer:InitializerGroup = new InitializerGroup();
MickeyInitializer.addInitializer( new SharedImage ( new Mickey()));
MickeyInitializer.addInitializer( new ScaleImageInit(0.1, 0.3));
MickeyInitializer.addInitializer( new Position( new RectangleZone( 0, 0, 1000, 500)));

emitter = new Emitter2D();
emitter.counter = new Blast(1);
renderer = new BitmapRenderer( new Rectangle ( 0, 0, 1000, 500));
emitter.addInitializer( new ChooseInitializer ( ([MickeyInitializer, AppleInitializer])) );
addChild(renderer);
renderer.addEmitter(emitter);
emitter.addInitializer( new Velocity ( new DiscZone (new Point (25, 25), 100)));

emitter.addAction( new WrapAroundBox(-100, -100, 1100, 700));
emitter.addAction( new Move());
emitter.start();

it does work if I use: emitter.counter = new Steady(1);
Thx for your help.
fred]]>
InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1652#Comment_1652 2011-06-13T08:10:47+01:00 2011-12-13T13:35:58+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Your counter, Blast(1), indicates you only want one particle. If you want to see both shapes you'll need to create more particles. e.g. emitter.counter = new Blast( 100 );
emitter.counter = new Blast( 100 );]]>
InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1653#Comment_1653 2011-06-13T16:25:59+01:00 2011-12-13T13:35:58+00:00 fred http://flintparticles.org/forum/account.php?u=510 Hey Richard, Thanks for your help. I guess I am not sure how to program what I am trying to do: I don't want 100 particles. I have 5 different shapes that I pulled from the library and I want to ... Thanks for your help.
I guess I am not sure how to program what I am trying to do:
I don't want 100 particles. I have 5 different shapes that I pulled from the library and I want to show only those 5 objects and use Flint to create interaction between them (like MutualGravity, Approach Neighbours etc ) ... Should I use 5 emitters?
Thanks again.
fred]]>
InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1654#Comment_1654 2011-06-13T22:14:13+01:00 2011-06-13T22:14:39+01:00 Richard http://flintparticles.org/forum/account.php?u=1 You could create a custom initializer to set the particles' images to each of the five shapes, and set the counter to a blast with a count of 5. Or, create instances of the five shapes and use the ...
Or, create instances of the five shapes and use the createParticles2DFromDisplayObjects method to create particles from them.]]>
InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1655#Comment_1655 2011-06-14T17:25:22+01:00 2011-12-13T13:35:58+00:00 fred http://flintparticles.org/forum/account.php?u=510 Hey Richard, Thanks a lot for your help. I managed to make it work :) I had to add an EventListener on "particleAdded" to start the emitter. If not, I get this error: TypeError: Error ... Thanks a lot for your help. I managed to make it work :)
I had to add an EventListener on "particleAdded" to start the emitter. If not, I get this error:

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChildAt()
at org.flintparticles.twoD.renderers::DisplayObjectRenderer/addParticle()[/actionScript/org/flintparticles/twoD/renderers/DisplayObjectRenderer.as:97]
at org.flintparticles.common.renderers::SpriteRendererBase/particleAdded()[/actionScript/org/flintparticles/common/renderers/SpriteRendererBase.as:151]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.flintparticles.common.emitters::Emitter/createParticle()[/actionScript/org/flintparticles/common/emitters/Emitter.as:661]
at org.flintparticles.common.emitters::Emitter/start()[/actionScript/org/flintparticles/common/emitters/Emitter.as:831]

So, here is the code:

public function CreateParticles()
{
emitter = new Emitter2D();
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer ();
addChild(renderer);
renderer.addEmitter(emitter);

////// These are assets in a swc file:
var myApple:Apple = new Apple();
var myMickey:Mickey = new Mickey();
var myCoca_cola:Coca_cola = new Coca_cola();
var myMac_Donalds:Mac_Donalds = new Mac_Donalds();
var myMarlboro:Marlboro = new Marlboro();
var myNike:Nike = new Nike();

var myArray:Array = [myApple, myMickey, myCoca_cola, myMac_Donalds, myMarlboro, myNike];

emitter.addInitializer( new Position( new RectangleZone( 0, 0, 1000, 500)));
emitter.addInitializer( new Velocity ( new DiscZone (new Point (25, 25), 10)));
emitter.addInitializer( new ScaleImageInit( 0.1, 0.2 ));
emitter.addAction( new WrapAroundBox(-100, -100, 1100, 600));
emitter.addAction( new Move());
emitter.addAction( new ApproachNeighbours(500, 10));

var myParticles:Vector.<Particle> = Particle2DUtils.createParticles2DFromDisplayObjects( myArray );

emitter.addEventListener("particleAdded", particleHandler);
emitter.addParticles( myParticles , true);
emitter.counter = new Blast(6);
//////// This creates an error >>> emitter.start();
}

protected function particleHandler(event:ParticleEvent):void
{
emitter.start();
}]]>
InitializerGroup question http://flintparticles.org/forum/comments.php?DiscussionID=491&Focus=1668#Comment_1668 2011-07-15T17:43:15+01:00 2011-12-13T13:35:58+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Try removing the blast counter. You don't want to create more particles, you've already created the six particle you need with this code var myParticles:Vector. = ...
var myParticles:Vector.<Particle> = Particle2DUtils.createParticles2DFromDisplayObjects( myArray );
emitter.addParticles( myParticles , true);


That should remove the error.]]>