home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / accessibility / ButtonAccImpl.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  2.7 KB  |  90 lines

  1. package mx.accessibility
  2. {
  3.    import flash.accessibility.Accessibility;
  4.    import flash.events.Event;
  5.    import flash.events.KeyboardEvent;
  6.    import flash.ui.Keyboard;
  7.    import mx.controls.Button;
  8.    import mx.core.UIComponent;
  9.    import mx.core.mx_internal;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class ButtonAccImpl extends AccImpl
  14.    {
  15.       mx_internal static const VERSION:String = "4.5.0.20967";
  16.       
  17.       public function ButtonAccImpl(param1:UIComponent)
  18.       {
  19.          super(param1);
  20.          role = AccConst.ROLE_SYSTEM_PUSHBUTTON;
  21.       }
  22.       
  23.       public static function enableAccessibility() : void
  24.       {
  25.          Button.mx_internal::createAccessibilityImplementation = mx_internal::createAccessibilityImplementation;
  26.       }
  27.       
  28.       mx_internal static function createAccessibilityImplementation(param1:UIComponent) : void
  29.       {
  30.          param1.accessibilityImplementation = new ButtonAccImpl(param1);
  31.       }
  32.       
  33.       override protected function get eventsToHandle() : Array
  34.       {
  35.          return super.eventsToHandle.concat(["click","labelChanged"]);
  36.       }
  37.       
  38.       override public function get_accState(param1:uint) : uint
  39.       {
  40.          var _loc2_:uint = getState(param1);
  41.          if(Button(master).selected)
  42.          {
  43.             _loc2_ |= AccConst.STATE_SYSTEM_PRESSED;
  44.          }
  45.          return _loc2_;
  46.       }
  47.       
  48.       override public function get_accDefaultAction(param1:uint) : String
  49.       {
  50.          return "Press";
  51.       }
  52.       
  53.       override public function accDoDefaultAction(param1:uint) : void
  54.       {
  55.          var _loc2_:KeyboardEvent = null;
  56.          if(master.enabled)
  57.          {
  58.             _loc2_ = new KeyboardEvent(KeyboardEvent.KEY_DOWN);
  59.             _loc2_.keyCode = Keyboard.SPACE;
  60.             master.dispatchEvent(_loc2_);
  61.             _loc2_ = new KeyboardEvent(KeyboardEvent.KEY_UP);
  62.             _loc2_.keyCode = Keyboard.SPACE;
  63.             master.dispatchEvent(_loc2_);
  64.          }
  65.       }
  66.       
  67.       override protected function getName(param1:uint) : String
  68.       {
  69.          var _loc2_:String = Button(master).label;
  70.          return _loc2_ != null && _loc2_ != "" ? _loc2_ : "";
  71.       }
  72.       
  73.       override protected function eventHandler(param1:Event) : void
  74.       {
  75.          $eventHandler(param1);
  76.          switch(param1.type)
  77.          {
  78.             case "click":
  79.                Accessibility.sendEvent(master,0,AccConst.EVENT_OBJECT_STATECHANGE);
  80.                Accessibility.updateProperties();
  81.                break;
  82.             case "labelChanged":
  83.                Accessibility.sendEvent(master,0,AccConst.EVENT_OBJECT_NAMECHANGE);
  84.                Accessibility.updateProperties();
  85.          }
  86.       }
  87.    }
  88. }
  89.  
  90.