Flint Particle System Forum - Snowflakes Reacting to Mouse Position Wed, 17 Nov 2010 11:55:05 +0000 http://flintparticles.org/forum/ Lussumo Vanilla 1.1.10 & Feed Publisher Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=540#Comment_540 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=540#Comment_540 Fri, 21 Nov 2008 20:24:11 +0000 mojo_j
emitter.addAction( new MouseAntiGravity (5, renderer));

This threw a bunch of errors like the one that follows:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at org.flintparticles.twoD.actions::MouseGravity/update()
at org.flintparticles.common.emitters::Emitter/update()
at org.flintparticles.common.emitters::Emitter/updateEventListener()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.flintparticles.common.utils::FrameUpdater/frameUpdate()

Any suggestions?

Also, if I wanted to add an emitter to the mouse point for snow particles would that be possible. Thanks in advance for any help. ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=541#Comment_541 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=541#Comment_541 Fri, 21 Nov 2008 21:07:46 +0000 mojo_j Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=546#Comment_546 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=546#Comment_546 Sun, 23 Nov 2008 07:08:23 +0000 alphagod
var emitter:Emitter2D = new Emitter2D();
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();

emitter.counter = new Steady( 150 );

emitter.addInitializer( new ImageClass( RadialDot, 2 ) );
emitter.addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 605, -5 ) ) ) );
emitter.addInitializer( new Velocity( new PointZone( new Point( 0, 65 ) ) ) );
emitter.addInitializer( new ScaleImageInit( 0.75, 2 ) );

emitter.addAction( new Move() );
emitter.addAction( new DeathZone( new RectangleZone( -10, -10, 620, 420 ), true ) );
emitter.addAction( new RandomDrift( 20, 20 ) );
emitter.addAction( new MouseAntiGravity (5, renderer));

renderer.addEmitter( emitter );
addChild( renderer );

emitter.start();
emitter.runAhead( 10 ); ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=550#Comment_550 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=550#Comment_550 Mon, 24 Nov 2008 14:07:30 +0000 mojo_j
And the layering works perfectly. That was exactly the effect I was looking for, but I modified the example you gave to set the layer position to 1 instead of 0 because I have a background that I want the snow to be in front of and then another little image that i want in front of the snow.

Thank you anyone for any help that can be provided with attaching the emitter to mouse point as described above and I'm glad I've chosen to use Flint because this is a very helpful community of Flash developers. ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=552#Comment_552 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=552#Comment_552 Mon, 24 Nov 2008 16:21:03 +0000 mojo_j
this.addEventListener(MouseEvent.MOUSE_OVER, callSnowFall2);

function callSnowFall2(evt:MouseEvent):void {

var emitter2:Emitter2D = new Emitter2D();
var renderer2:DisplayObjectRenderer = new DisplayObjectRenderer();

emitter2.counter = new Steady( 150 );

emitter2.addInitializer( new ImageClass( RadialDot, 2 ) );
emitter2.addInitializer( new Position( new LineZone( new Point( -5, -5 ), new Point( 765, -5 ) ) ) );
emitter2.addInitializer( new Velocity( new PointZone( new Point( 0, 65 ) ) ) );
emitter2.addInitializer( new ScaleImageInit( 0.75, 1.5 ) );

emitter2.addAction( new Move() );
emitter2.addAction( new DeathZone( new RectangleZone( -10, -10, 780, 600 ), true ) );
emitter2.addAction( new RandomDrift( 100, 20 ) );

renderer2.addEmitter( emitter2 );
addChild( renderer2 );
setChildIndex(renderer2, 1);

emitter2.start();
emitter2.runAhead( 10 );

}

I've managed to create a new emitter when the user mouses over the stage. What I can't figure out how to do is dispose of the emitter once the user mouses out of the movie. I've tried a similar tactic listening for the mouse out event, but the function I wrote for that event wouldn't allow me to access emitter2 to dispose of it. I'm sure there has to be an easier way to do this within the Flint system, but I am really lost with ActionScript. I'd also like to attach the emitter to the mouse instead of a fixed point above the stage. Any help with this would be greatly appreciated. ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=554#Comment_554 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=554#Comment_554 Mon, 24 Nov 2008 19:23:23 +0000 Richard
stage.addEventListener( Event.MOUSE_LEAVE, leave );
stage.addEventListener( MouseEvent.MOUSE_MOVE, enter );

private function leave( ev:Event ):void
{
emitter.counter.stop();
}
private function enter( ev:Event ):void
{
emitter.counter.resume();
}
]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=555#Comment_555 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=555#Comment_555 Mon, 24 Nov 2008 20:14:26 +0000 mojo_j Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=607#Comment_607 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=607#Comment_607 Thu, 08 Jan 2009 21:18:50 +0000 mastaflint
I tried TurnAwayFromMouse but that was even more dramatic.
I'm reading into BoundingBox, Bounce...and Gravity Well--but Gravity Well would be more the opposite of what I want to do.

I guess what I'm trying to say is have MouseAntiGravity only effect the particle until it was far enough away from the mouse that it would revert back to it's normal trajectory. ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=608#Comment_608 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=608#Comment_608 Thu, 08 Jan 2009 23:06:35 +0000 mastaflint
if(d < 30) {
p.velX += x * factor;
p.velY += y * factor;
}
else {
continue doing what you were doing
}

Problem is, how do I store that Velocity and RandomDrift and apply it again to the particles? ]]>
Snowflakes Reacting to Mouse Position http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=610#Comment_610 http://flintparticles.org/forum/comments.php?DiscussionID=138&Focus=610#Comment_610 Fri, 09 Jan 2009 08:13:10 +0000 Richard
if(d < 30) {
if( p.dictionary[this] == null ) {
p.dictionary[this] = { velX: p.velX, velY: p.velY };
}
p.velX += x * factor;
p.velY += y * factor;
} else {
if( p.dictionary[this] != null ) {
var obj:Object = p.dictionary[this];
p.velX = obj.velX;
p.velY = obj.velY;
p.dictionary[this] = null;
}
}
]]>