0 Replies Latest reply on Feb 11, 2010 3:20 PM by jeremybixby

    SWFLoader and custom Effect

    jeremybixby

      I am having an issue figuring out custom Effects that are based on playing a SWF.  When I try to play the custom effect on my Effect subclass, I get a message in the console that says we loaded the SWF but it does not in fact play on the UIComponent.  Could somebody take a quick peek at my code and let me know what they think?

       

      package us.ks.lenexa.Graphics.Effects

      {

      import mx.controls.SWFLoader;

      import mx.effects.EffectInstance;

       

      /**This class holds out info about what the effect does.

      **/

      public class RedGlowInstance extends EffectInstance

      {

      //the flash glow object

      //[Embed(source="us/ks/lenexa/assets/flash/Red_glow.swf")]

      //public var redglow:Class;

       

      private var _redGlow:SWFLoader = new SWFLoader();

       

       

      public function RedGlowInstance(target:Object)

      {

      _redGlow.source = "us/ks/lenexa/assets/flash/Red_glow.swf";

      _redGlow.height = 80;

      _redGlow.width = 80;

      _redGlow.visible = true;

      _redGlow.load();

      super(target);

      }

       

      // Override play() method.

              override public function play():void {

                  _redGlow.visible = true;

                  super.play();

       

              }

       

              // Override end() method class to stop the SWFLoader

              override public function end():void {

                  //_redGlow.visible = false;

                  super.end();

              }

       

      }

      }

       

       

       

      package us.ks.lenexa.Graphics.Effects

      {

      import mx.effects.Effect;

      import mx.effects.EffectInstance;

      import mx.effects.IEffectInstance;

       

      /**This class defines a custom effect that is the basis for the

      **/

      public class RedGlowEffect extends Effect

      {

      public function RedGlowEffect(target:Object=null)

      {

      super(target);

      instanceClass = RedGlowInstance;

      }

       

      override public function getAffectedProperties():Array{

      return [];

      }

       

      // Override initInstance() method.

             override protected function initInstance(inst:IEffectInstance):void {

                 super.initInstance(inst);

             }

       

      }

      }

       

       

      package us.ks.lenexa.Graphics

      {

      import com.esri.ags.Graphic;

      import com.esri.ags.geometry.Geometry;

      import com.esri.ags.symbol.Symbol;

       

      import flash.events.MouseEvent;

       

      import us.ks.lenexa.Graphics.Effects.RedGlowEffect;

       

      /**Class plays a red-glow swf effect when the user mouses over the graphic

      **/

      public class GlowGraphic extends Graphic

      {

      //here we have our redGLow

      public var redGlowEffect:RedGlowEffect = new RedGlowEffect(this);

       

      public function GlowGraphic(geometry:Geometry=null, symbol:Symbol=null, attributes:Object=null, playRedGlow:Boolean = false)

      {

      super(geometry, symbol, attributes);

       

      if(playRedGlow==true){

      PlayRedGlow();

      }

      }

       

      public function PlayRedGlow():void{

       

      this.addEventListener(MouseEvent.ROLL_OVER, playRedGlowFunct);

      this.addEventListener(MouseEvent.ROLL_OUT, stopRedGlow);

       

      }

       

      private function playRedGlowFunct(e:MouseEvent):void{

       

      //redGlowEffect.duration = 10000;

      //var g:GlowGraphic = e.target as GlowGraphic;

      redGlowEffect.play([this]);

       

       

      }

       

      private function stopRedGlow(e:MouseEvent):void{

       

      redGlowEffect.stop();

      }

       

      }

      }