Flint Particle System Forum - Help with my code for making an emitter follow a movieclip on stage Mon, 12 Dec 2011 00:47:29 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Help with my code for making an emitter follow a movieclip on stage http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=591#Comment_591 http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=591#Comment_591 Tue, 30 Dec 2008 08:45:51 +0000 awesomerami
I would appreciate it immensely if i could get some feedback on my code for getting an emitter (some stars) to follow a movieclip (called fly_mc) on stage. It seems that i managed successfully to pull it off, just the frame rate dies after a few seconds.

I created my own custom class from MoveEmitter.as and called it EmFollowMc.as

Here is the code for EmFollowMc.as:

package org.flintparticles.twoD.activities
{
import org.flintparticles.common.activities.ActivityBase;
import org.flintparticles.common.emitters.Emitter;
import org.flintparticles.twoD.emitters.Emitter2D;
import flash.display.DisplayObject;

public class EmFollowMc extends ActivityBase
{

private var _mcname:DisplayObject;

public function EmFollowMc ( image:DisplayObject )
{

_mcname = image;
}

override public function update( emitter : Emitter, time : Number ) : void
{
var e:Emitter2D = Emitter2D( emitter );
e.x = _mcname.x;
e.y = _mcname.y;

}
}
}


And now the code in the first frame of my timeline:


var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Steady(10);

emitter.addInitializer( new ImageClass( Star, 5 ) );
emitter.addInitializer( new Position( new RectangleZone( 100,100,160,160) ) );
emitter.addInitializer( new Lifetime( 1, 2 ) );


emitter.addAction( new Move() );
emitter.addAction( new Age() );

emitter.addActivity( new EmFollowMc (fly_mc));

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer;
renderer.addEmitter( emitter );
addChild( renderer );
emitter.start( );



I'm manually tweening the fly_mc movieclip across the stage and the particles follow nicely. It's just that the frame rate commits suicide after just a couple of seconds, and it's only a Steady(10).

Thanks for taking the time to read this and i hope i've posted this in such a way that makes it easy to interpret. Thanks again. ]]>
Help with my code for making an emitter follow a movieclip on stage http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=600#Comment_600 http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=600#Comment_600 Wed, 07 Jan 2009 08:27:07 +0000 Richard Help with my code for making an emitter follow a movieclip on stage http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=1483#Comment_1483 http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=1483#Comment_1483 Sat, 18 Dec 2010 02:01:16 +0000 notsuj
The EmfollowMc.as file is the same as above and in the right spot. Below is the code from frame #1 (same as above):
--------------
import org.flintparticles.common.counters.*;
import org.flintparticles.common.displayObjects.RadialDot;
import org.flintparticles.common.initializers.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.Emitter2D;
import org.flintparticles.twoD.initializers.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.activities.*;


addChild( new SnowBackground() );

var emitter:Emitter2D = new Emitter2D();
emitter.counter = new Steady(2);

emitter.addInitializer( new ImageClass( Star, 5 ) );
emitter.addInitializer( new Position( new RectangleZone( 100,100,100,100) ) );
emitter.addInitializer( new Lifetime( 1, 2 ) );


emitter.addAction( new Move() );


emitter.addActivity( new EmFollowMc (emitterMove));

var renderer:DisplayObjectRenderer = new DisplayObjectRenderer;
renderer.addEmitter( emitter );
addChild( renderer );
emitter.start( );
----------

I get this error:
1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.

It is referring to this line: emitter.addActivity( new EmFollowMc (emitterMove).

The emitterMove mc is exported for AS. Again I am not a CS major, but if I can get this working, I can use it in my concept animations before they go to engineering for implementation into our custom software package. ]]>
Help with my code for making an emitter follow a movieclip on stage http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=1488#Comment_1488 http://flintparticles.org/forum/comments.php?DiscussionID=148&Focus=1488#Comment_1488 Mon, 20 Dec 2010 08:06:02 +0000 Richard FollowDisplayObjectactivity to Flint. ]]>