/* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license */ package com.yahoo.astra.fl.accessibility { import com.yahoo.astra.accessibility.EventTypes; import com.yahoo.astra.accessibility.ObjectRoles; import com.yahoo.astra.accessibility.ObjectStates; import com.yahoo.astra.fl.controls.mediaPlayerClasses.MediaInfoView; import fl.accessibility.AccImpl; import fl.core.UIComponent; import flash.accessibility.Accessibility; import flash.events.Event; /** * The MediaInfoViewAccImpl class is the accessibility class for MediaInfoView, used in AudioPlayback. * * @author Alaric Cole * */ public class MediaInfoViewAccImpl extends AccImpl { //-------------------------------------------------------------------------- // // Class initialization // //-------------------------------------------------------------------------- /** * @private * Static variable triggering the hookAccessibility() method. * This is used for initializing DateChooserAccImpl class to hook its * createAccessibilityImplementation() method to DateChooser class * before it gets called from UIComponent. */ private static var accessibilityHooked:Boolean = hookAccessibility(); /** * @private * Static method for swapping the createAccessibilityImplementation() * method of MediaInfoView withthe MediaInfoViewAccImpl class. */ private static function hookAccessibility():Boolean { MediaInfoView.createAccessibilityImplementation = createAccessibilityImplementation; return true; } //-------------------------------------------------------------------------- // // Class constants // //-------------------------------------------------------------------------- override public function getChildIDArray():Array { var childIDs:Array = []; return childIDs; } //-------------------------------------------------------------------------- // // Class methods // //-------------------------------------------------------------------------- /** * @private * Method for creating the Accessibility class. * This method is called from UIComponent. */ public static function createAccessibilityImplementation(component:UIComponent):void { component.accessibilityImplementation = new MediaInfoViewAccImpl(component); } /** * Method call for enabling accessibility for a component. * This method is required for the compiler to activate * the accessibility classes for a component. */ public static function enableAccessibility():void { } //-------------------------------------------------------------------------- // // Constructor // //-------------------------------------------------------------------------- /** * Constructor. * * @param master The UIComponent instance that this AccImpl instance * is making accessible. */ public function MediaInfoViewAccImpl(master:UIComponent) { super(master); role = ObjectRoles.ROLE_SYSTEM_TEXT; } /** * @private * Array of events that we should listen for from the master component. */ override protected function get eventsToHandle():Array { return super.eventsToHandle.concat([ "change" ]); } /** * @inheritDoc */ override public function get_accRole(childID:uint):uint { return role; } /** * @inheritDoc */ override public function get_accValue(childID:uint):String { return MediaInfoView(master).text; } /** * @inheritDoc */ override protected function getName(childID:uint):String { return "Current track " + get_accValue(childID); } /** * @inheritDoc */ override public function get_accState(childID:uint):uint { var accState:uint = getState(childID); var master:MediaInfoView = MediaInfoView(master); accState |= ObjectStates.STATE_SYSTEM_FOCUSABLE; accState |= ObjectStates.STATE_SYSTEM_READONLY; return accState; } /** * @inheritDoc */ override protected function eventHandler(event:Event):void { if (event.type == "change") { //Accessibility.sendEvent(master, 0, EventTypes.EVENT_OBJECT_VALUECHANGE, true) } } } }