Flint Particle System Forum - Help with my code for making an emitter follow a movieclip on stage 2011-12-12T01:10:04+00:00 http://flintparticles.org/forum/ Lussumo Vanilla & 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 2008-12-30T08:45:51+00:00 2009-01-07T08:22:44+00:00 awesomerami http://flintparticles.org/forum/account.php?u=129 Hi Richard and everyone on this forum. I'm a beginner with Flint and i think it's an awesome particle system with enormous potential. I would appreciate it immensely if i could get some feedback ...
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 2009-01-07T08:27:07+00:00 2011-12-12T01:10:04+00:00 Richard http://flintparticles.org/forum/account.php?u=1 I can't see any problems in the code you've posted. What happens if you don't tween fly_mc but keep everything else the same? 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 2010-12-18T02:01:16+00:00 2011-12-12T01:10:04+00:00 notsuj http://flintparticles.org/forum/account.php?u=450 I am digital artist now using flash every day and I need to be able to integrate particles into my workflow. I have been using Flint for the last couple days getting familiar with the basics of ...
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 2010-12-20T08:06:02+00:00 2011-12-12T01:10:04+00:00 Richard http://flintparticles.org/forum/account.php?u=1 Sometime after the discussion above I added the FollowDisplayObjectactivity to Flint. FollowDisplayObjectactivity to Flint.]]>