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

    • CommentAuthorneonblue
    • CommentTimeApr 17th 2010
     
    I've been playing with http://flintparticles.org/examples/logo-firework on this site.

    Is there a way to do this effect with just plain text without using a bitmap? For example, I'd like to pass in a word or phrase and have this effect played on it.

    Thanks.
    • CommentAuthorRichard
    • CommentTimeApr 17th 2010
     
    If you use a DisplayObjectZone in the Velocity initializer, using a TextField as the display object, it should work.
    • CommentAuthorneonblue
    • CommentTimeApr 19th 2010
     
    I did it this way... Is there an easier way? Also the word is not really that legible.. Is there a way I can sharpen the text?

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute" width="400" height="300"
    creationComplete="init()">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    import flash.filters.BlurFilter;
    import flash.filters.ColorMatrixFilter;
    import flash.geom.Point;
    import flash.text.TextField;

    import mx.core.UIComponent;
    import mx.logging.Log;

    import org.flintparticles.common.actions.Age;
    import org.flintparticles.common.actions.Fade;
    import org.flintparticles.common.counters.*;
    import org.flintparticles.common.displayObjects.RadialDot;
    import org.flintparticles.common.energyEasing.Quadratic;
    import org.flintparticles.common.events.EmitterEvent;
    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.*;

    private var emitter:Emitter2D = new Emitter2D();
    private var tfldTextString:TextField = new TextField();
    private var tfFormat:TextFormat = new TextFormat();
    [Bindable] private var bmGraphicString:BitmapData = new BitmapData(300,200,true,0x00FFFFFF);

    private function init():void
    {
    var cnvs:UIComponent = new UIComponent();
    emitter.counter = new Blast( 6000 );

    CreateWord("H o o r a y !!");

    emitter.addInitializer( new ColorInit( 0xFFFF3300, 0xFFFFFF00 ) );
    emitter.addInitializer( new Lifetime( 6 ) );
    emitter.addInitializer( new Position( new DiscZone( new Point( 0, 0 ), 10 ) ) );

    emitter.addInitializer( new Velocity( new BitmapDataZone( bmGraphicString, -132, -300 ) ) );

    emitter.addAction( new Age( Quadratic.easeIn ));
    emitter.addAction( new Fade( 1.0, 0 ) );
    emitter.addAction( new Move() );
    emitter.addAction( new LinearDrag( 0.5 ) );
    emitter.addAction( new Accelerate( 0, 70 ) );

    emitter.addEventListener( EmitterEvent.EMITTER_EMPTY, restart );

    var renderer:PixelRenderer = new PixelRenderer( new Rectangle( 0, 0, 500, 300 ) );
    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.96,0 ] ) );
    renderer.addEmitter( emitter );

    this.addElement( cnvs );
    cnvs.addChild( renderer );

    renderer.addEmitter( emitter );
    emitter.x = 250;
    emitter.y = 300;
    emitter.start( );
    }

    private function CreateWord( szString:String ): void
    {

    tfldTextString.autoSize = TextFieldAutoSize.LEFT;
    tfFormat.bold = true;
    tfFormat.size = 60;
    tfFormat.color = 0x000000;
    tfldTextString.defaultTextFormat = tfFormat;
    tfldTextString.text = szString;
    tfldTextString.x = 150 - tfldTextString.width/2;
    tfldTextString.y = 20;
    bmGraphicString.draw(tfldTextString, tfldTextString.transform.matrix);
    }

    private function restart( ev:EmitterEvent ):void
    {
    Emitter2D( ev.target ).start();
    }



    ]]>
    </fx:Script>

    </mx:Module>
    • CommentAuthorRichard
    • CommentTimeApr 20th 2010 edited
     
    To remove the blur, use a PointZone for the Position initializer

    emitter.addInitializer( new Position( new PointZone( new Point( 0, 0 ) ) ) );

    Or remove it altogether (placing new particles at 0,0 is the default position behaviour).