topical media & game development

talk show tell print

student-game-wakuwaku-com-waku-components-ImageButton.ax

student-game-wakuwaku-com-waku-components-ImageButton.ax (swf ) [ flash ] flex


  package //com.waku.components
  {
          import flash.events.Event;
          import flash.events.MouseEvent;
          
          import mx.controls.Image;
          import mx.containers.Canvas;
          import mx.events.EffectEvent;
          import mx.core.ScrollPolicy;
          public class @ax-student-game-wakuwaku-com-waku-components-ImageButton extends Canvas
          {
                  public var animalId : int;
                  public var itemId : int;
                  public var visualTransformation : student_game_wakuwaku_com_waku_components_VisualTransformation;
                  public var mouseOverEffectisPlaying : Boolean = new Boolean();
                  
                  public function @ax-student-game-wakuwaku-com-waku-components-ImageButton()
                  {
                          visualTransformation = new student_game_wakuwaku_com_waku_components_VisualTransformation(this);
                          this.addEventListener(MouseEvent.ROLL_OVER, rollOverMenuItemEventHandler);
                          this.addEventListener(MouseEvent.ROLL_OUT, rollOutMenuItemEventHandler);
                          this.visualTransformation.dissolveEffectIn.addEventListener(EffectEvent.EFFECT_END, dissolveEffectInEndHandler);
                          this.horizontalScrollPolicy = ScrollPolicy.OFF;
                          this.verticalScrollPolicy = ScrollPolicy.OFF;
                          
                          
                          
                  }
                  
                  public function addSource(urlImage:String): void {
                          var itemImage : Image = new Image;
                          itemImage.source=urlImage;
                          this.addChild(itemImage);
                          
                  }
                  
                  public function enableAnimation():void
                  {
                          this.addEventListener(MouseEvent.ROLL_OVER, rollOverMenuItemEventHandler);
                          this.addEventListener(MouseEvent.ROLL_OUT, rollOutMenuItemEventHandler);
                          this.visualTransformation.dissolveEffectIn.addEventListener(EffectEvent.EFFECT_END, dissolveEffectInEndHandler);        
                  }
                  
                  public function disableAnimation():void
                  {
                          this.removeEventListener(MouseEvent.ROLL_OVER, rollOverMenuItemEventHandler);
                          this.visualTransformation.dissolveEffectIn.removeEventListener(EffectEvent.EFFECT_END, dissolveEffectInEndHandler);
                          //this.visualTransformation.dissolveEffectIn.stop();
                          //this.visualTransformation.dissolveEffectOut.stop();
                          
                          //this.visualTransformation.disabledColorTransform();
                  }
                  
                  private function dissolveEffectInEndHandler(event : EffectEvent) : void {
                          if (this.mouseOverEffectisPlaying){
  
                                  this.visualTransformation.dissolveEffectIn.play();
                          }
                          else 
                          {
                                  this.visualTransformation.dissolveEffectIn.end();
                                  //this.visualTransformation.dissolveEffectOut.play();
                          }
                          
                  }
                  
                  private function dissolveEffectOutEndHandler(event : EffectEvent) : void {
                          if (this.mouseOverEffectisPlaying){
                                  this.visualTransformation.dissolveEffectOut.play();
                          }
                          else 
                          {
                                  this.visualTransformation.dissolveEffectIn.reverse();
                                  this.visualTransformation.dissolveEffectOut.play();
                          }
                  }
                  
                  private function rollOverMenuItemEventHandler(event:Event):void {
                          var imageButton : @ax-student-game-wakuwaku-com-waku-components-ImageButton = event.currentTarget as @ax-student-game-wakuwaku-com-waku-components-ImageButton;
                          if( !imageButton.visualTransformation.dissolveEffectIn.isPlaying) {
                                  this.mouseOverEffectisPlaying=true;
                                  imageButton.visualTransformation.dissolveEffectIn.play();
                          }
                                  
                  }
                  
                  private function rollOutMenuItemEventHandler(event:Event):void{
                          var imageButton : @ax-student-game-wakuwaku-com-waku-components-ImageButton = event.currentTarget as @ax-student-game-wakuwaku-com-waku-components-ImageButton;
                          if( imageButton.visualTransformation.dissolveEffectIn.isPlaying)
                          {
                                  this.mouseOverEffectisPlaying=false;
                                  //imageButton.visualTransformation.dissolveEffectIn.stop();
                          }
                  }
          }
  }


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.