topical media & game development

talk show tell print

animation-ch13-TwoSegments2.ax

animation-ch13-TwoSegments2.ax [swf] [flash] flex


  package {
          import flash.display.Sprite;
          import flash.display.StageScaleMode;
          import flash.display.StageAlign;
          import flash.events.Event;
  
          public class @ax-animation-ch13-TwoSegments2 extends Sprite
          {
                  private var slider0:animation_ch13_SimpleSlider;
                  private var slider1:animation_ch13_SimpleSlider;
                  private var segment0:animation_ch13_Segment;
                  private var segment1:animation_ch13_Segment;
                  
                  public function @ax-animation-ch13-TwoSegments2()
                  {
                          init();
                  }
                  
                  private function init():void
                  {
                          stage.scaleMode = StageScaleMode.NO_SCALE;
                          stage.align = StageAlign.TOP_LEFT;
                          
                          segment0 = new animation_ch13_Segment(100, 20);
                          addChild(segment0);
                          segment0.x = 100;
                          segment0.y = 100;
                          
                          segment1 = new animation_ch13_Segment(100, 20);
                          addChild(segment1);
                          segment1.x = segment0.getPin().x;
                          segment1.y = segment0.getPin().y;
                          
                          slider0 = new animation_ch13_SimpleSlider(-90, 90, 0);
                          addChild(slider0);
                          slider0.x = 320;
                          slider0.y = 20;
                          slider0.addEventListener(Event.CHANGE, onChange);
  
                          slider1 = new animation_ch13_SimpleSlider(-160, 0, 0);
                          addChild(slider1);
                          slider1.x = 340;
                          slider1.y = 20;
                          slider1.addEventListener(Event.CHANGE, onChange);
                  }
                  
                  private function onChange(event:Event):void
                  {
                          segment0.rotation = slider0.value;
                          segment1.rotation = segment0.rotation + slider1.value;
                          segment1.x = segment0.getPin().x;
                          segment1.y = segment0.getPin().y;
                  }
          }
  }
  


(C) Æliens 04/09/2009

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.