<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
  layout="absolute"
  xmlns:core="com.ptaylor.effects.core.*"
  xmlns:efx="com.ptaylor.effects.*"
  xmlns:extras="com.ptaylor.effects.extras.*"
  xmlns:geom="flash.geom.*"
  xmlns:mx="http://www.adobe.com/2006/mxml"
  creationComplete="init()"
  frameRate="30"
  pageTitle="Particle Emitter Demo"
   viewSourceURL="srcview/index.html">
  <!-- 
    Use the Particle Emitter Publishing Tool (available at http://guyinthechair.com/?p=61)
    to mock up the effects. You can copy and paste code generated in that tool to implement
    the actual effects here.
   -->
  <mx:Script>
    <![CDATA[
      import com.ptaylor.effects.core.ColorEffect;
      import com.ptaylor.effects.core.FilterEffect;
      import com.ptaylor.effects.extras.Emitter;
      import com.flashdynamix.utils.SWFProfiler;
      
      protected function init():void
      {
        callLater(SWFProfiler.init, [this]);
        callLater(SWFProfiler.start);
        //Uncomment this to create the emitter through Actionscript
        //createEmitter();
      }
      
      [Embed('assets/particles.swf#Stars')]
      private var stars:Class;
      
      protected function createEmitter():void
      {
        var e:Emitter = new Emitter(stars, {alpha:1, scaleY:2, rotation:"0,0", scaleX:2}, 1, 0.75, "215,290", "50,130", 1, BlendMode.NORMAL);
        e.x = 200;
        e.y = 200;
        e.scaleX = 0.5;
        e.scaleY = 0.5;
        e.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 255, 0);
        e.endColor = new ColorTransform(1, 1, 1, 1, 255, 0, 0, 0);
        emitterCanvas.emitters = [e];
        
        var bf:FilterEffect = new FilterEffect(new BlurFilter(1, 1, 3));
        var cf:ColorEffect = new ColorEffect(new ColorTransform(1, 1, 1, 0.9071618037135278, 0, 0, 0, 0));
        var gf:FilterEffect = new FilterEffect(new GlowFilter(0xffff00, 0.054901960784313725, 20, 20, 2, 3, true, false));
        
        emitterCanvas.effects = [bf, cf, gf];
      }
    ]]>
  </mx:Script>
  <!-- 
    This creates the emitters via MXML. If you create the emitter through Actionscript,
    leave the EmitterCanvas declaration and comment out the emitters and effects declarations.
   -->
  <efx:EmitterCanvas 
    height="500"
    id="emitterCanvas"
    width="500"
    x="{(width - emitterCanvas.width) / 2}"
    y="{(height - emitterCanvas.height) / 2}"
    >
    <efx:emitters>
      <mx:Array>
        <extras:Emitter 
          scaleX="0.5"
          scaleY="0.5"
          x="225"
          y="225"
          particle="@Embed('assets/particles.swf#Stars')"
          target="{{alpha:1, scaleY:2, rotation:'0,0', scaleX:2}}"
          random=".75"
          frequency="1"
          angle="215,290"
          distance="50,130"
          speed="1"
          blendMode="{BlendMode.NORMAL}"
          colorTransform="{new ColorTransform(1, 1, 1, 1, 0, 0, 255, 0)}"
          endColor="{new ColorTransform(1, 1, 1, 1, 255, 0, 0, 0)}"
          />
      </mx:Array>
    </efx:emitters>
    <efx:effects>
      <mx:Array>
        <core:FilterEffect id="blurEffect">
          <core:filter>
            <mx:BlurFilter blurX="1"
              blurY="1"
              quality="3"
              />
          </core:filter>
        </core:FilterEffect>
        <core:ColorEffect id="colorEffect">
          <core:colorTransform>
            <geom:ColorTransform redMultiplier="1"
              blueMultiplier="1"
              greenMultiplier="1"
              alphaMultiplier="0.91"
              />
          </core:colorTransform>
        </core:ColorEffect>
        <core:FilterEffect id="glowEffect">
          <core:filter>
            <mx:GlowFilter color="0xFFFF00"
              alpha="0.055"
              blurX="20"
              blurY="20"
              strength="2"
              quality="3"
              inner="true"
              knockout="false"
              />
          </core:filter>
        </core:FilterEffect>
      </mx:Array>
    </efx:effects>
  </efx:EmitterCanvas>
</mx:Application>