Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorbbigger
    • CommentTimeMay 19th 2008 edited
     
    Is there a way to fade all particles and then remove them from a function call. I'd like to be able to remove all the particles quickly to transition to another section of a movie.

    Thanks!
    • CommentAuthorRichard
    • CommentTimeMay 19th 2008
     
    Easiest way would be to fade the renderer. The renderer is just a DisplayObject so use any method you like to reduce its alpha.

    When you're done, call dispose() on the emitter to clean up the particles neatly, and if you're using a BitmapRenderer or PixelRenderer, call dispose() on that too to free the memory used by the bitmapData object.
    • CommentAuthorrobotz
    • CommentTimeMay 21st 2008
     
    Is there a way to do this if more than one emitter is sharing a renderer?
    • CommentAuthorericr
    • CommentTimeMay 21st 2008
     
    Algorithm to do what you want:
    1) Fade out the renderer.
    2) Loop through your Emitter objects and call "emitter.dispose()" on each.
    3) Call "renderer.dispose()" on your FullStagePixelRenderer (assuming the code you posted in another thread).

    That should clean everything up for you.
    • CommentAuthorluka66_6
    • CommentTimeNov 20th 2008
     
    I would like to ask for some clarification on this as i can not make this happen. Particles fade out nicely for the first time but when i hover over my display object again and again i only see particles for a fraction of a second. What am i doing wrong? Any help is very appriciated. Here is my code:

    import flash.geom.Point;
    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.*;

    var emitter:Emitter2D = new Emitter2D();

    emitter.counter = new Blast( 2000 );

    emitter.addInitializer( new ColorInit( 0xFFFF00FF, 0xFF00FFFF ) );
    emitter.addInitializer( new Position( new DiscZone( new Point( 75, 17.5 ), 150 ) ) );

    emitter.addAction( new Move() );

    emitter.addAction( new GravityWell( 25, 75, 17.5 ) );

    var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 150, 35 ) );
    renderer.addFilter( new BlurFilter( 2, 2, 1 ) );
    renderer.addFilter( new ColorMatrixFilter( [ 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0.99,0 ] ) );

    this.btn.addEventListener(MouseEvent.MOUSE_OVER, particleShow)

    function particleShow(event:MouseEvent):void
    {
    renderer.addEmitter( emitter );
    addChild( renderer );
    emitter.start();
    renderer.alpha = 1;
    }

    this.btn.addEventListener(MouseEvent.MOUSE_OUT, particleStop)

    function particleStop(event:MouseEvent):void
    {
    renderer.addEventListener(Event.ENTER_FRAME, particleFade);
    }

    function particleFade(event:Event):void
    {
    renderer.alpha -= 0.1;
    if(renderer.alpha <= 0.2)
    {
    removeEmitter( emitter );
    }
    }

    if i add removeChild( renderer ); to my particleFade function i get an error: ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()

    like i said any help would be great i love this system and i really like to be able to give my buttons nice roll on and out with particles fade effects.

    regards
    Luka
    • CommentAuthorluka66_6
    • CommentTimeNov 22nd 2008
     
    I would still require some help for fading and removing paticles from stage gradually. Please.

    regards
    Luka
    • CommentAuthorRichard
    • CommentTimeNov 22nd 2008
     
    Try this

    function particleFade(event:Event):void{
    renderer.alpha -= 0.1;
    if (renderer.alpha<=0.2)
    {
    emitter.stop();
    renderer.removeEmitter( emitter );
    renderer.removeEventListener(Event.ENTER_FRAME, particleFade);
    removeChild( renderer );
    }
    }
    • CommentAuthorluka66_6
    • CommentTimeNov 22nd 2008
     
    Tnx. very much. :) It works like charm now. :)