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

    • CommentAuthorLanceMango
    • CommentTimeMay 19th 2011
     
    Hello,
    i have a growing gras animation. 3 buttons: start the animation, pause the animation and one for cleanig up the stage.
    Start and Pause are working without problems, but i'm desperating with the cleaning button. i tried many many ways, nothing worked.
    please, can anyone help?
    here ist the code:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:f="http://flintparticles.org/2009/flint2d"
    width="500" height="500"
    backgroundColor="#000000">

    <fx:Script>
    <![CDATA[
    import mx.core.mx_internal;

    import org.flintparticles.common.events.EmitterEvent;
    import org.flintparticles.common.events.ParticleEvent;
    import org.flintparticles.common.particles.Particle;
    import org.flintparticles.twoD.particles.Particle2D;
    import org.flintparticles.twoD.particles.Particle2DUtils;
    import org.flintparticles.twoD.particles.ParticleCreator2D;

    protected function start(event:MouseEvent):void
    {
    emitter.start();

    }

    protected function pause(event:MouseEvent):void
    {
    emitter.pause();
    }

    protected function reset(event:MouseEvent):void
    {
    // emitter.killAllParticles();
    // emitter.removeParticles( emitter.particles ) ;

    }

    ]]>
    </fx:Script>
    <s:Rect width="500" height="500" x="0" y="0">
    <s:fill>
    <s:BitmapFill source="@Embed('bilder/bg.png')"/>

    </s:fill>
    </s:Rect>

    <f:BitmapLineRenderer width="500" height="500">
    <f:emitters>
    <f:Emitter id="emitter" autoStart="false" x="250" y="400" runAheadTime="0" >
    <f:counter>
    <f:Blast startCount="100"/>
    </f:counter>
    <f:initializers >
    <f:Position>
    <f:DiscZone centerX="0" centerY="0" outerRadius="100"/>
    </f:Position>
    <f:Velocity>
    <f:DiscSectorZone centerX="0" centerY="0" outerRadius="80" innerRadius="40" minAngle="{-5 * Math.PI / 8}" maxAngle="{-3 * Math.PI / 8}"/>
    </f:Velocity>
    <f:ColorInit minColor="0xFF718f3a" maxColor="0xFF8dac35"/>
    <f:Lifetime lifetime="7"/>
    </f:initializers>
    <f:actions>

    <f:Move/>
    <f:Age/>
    <f:Accelerate x="0" y="10"/>
    <f:ScaleImage startScale="1" endScale="1"/>

    </f:actions>
    </f:Emitter>
    </f:emitters>
    </f:BitmapLineRenderer>

    <s:Group x="100" y="470">

    <s:Button x="0" label="start" click="start(event)"/>
    <s:Button x="120" label="stop!" click="pause(event)"/>
    <s:Button x="220" id="cut" label="clean stage" click="reset(event)"/>

    </s:Group>

    </s:Application>
    • CommentAuthorRichard
    • CommentTimeMay 23rd 2011 edited
     
    Hmm. Don't know how I missed the need to clear the content of the renderer. Until I add such a method, you'll have to clear the renderer by hand...

    protected function reset(event:MouseEvent):void
    {
    emitter.killAllParticles();
    renderer.bitmapData.fillRect( emitter.bitmapData.rect, 0 );
    }

    ...

    <f:BitmapLineRenderer id="renderer" width="500" height="500">