Login Latest Snippets Home My Account
Snippee! A personal code snippet manager... Store, share, organize! ...

MSAAHelper.as

Published: 2011-08-11 19:05:18 - In: AS3

import au.edu.griffith.eps.utils.MSAAHelper; public function updateMSAA():void { var update_msaa:MSAAHelper = new MSAAHelper(this, 7); }

package au.edu.griffith.eps.utils {

	/*
	 *  The following class corrects the tab order for components in a 
	 *  Flex container (HBox, VBox, Panel...).
	 *
	 *  Requirements: container item and starting index.
	 *
	 *  Warning: Components that are not included will be given tab indexes 
	 *  automatically by Flex.
	 */


    import flash.accessibility.Accessibility;
    import flash.display.InteractiveObject;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    import flash.system.Capabilities;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;

    import mx.core.Container;
    import mx.core.UITextField;
    import mx.core.mx_internal;
    import mx.events.FlexEvent;

    import mx.core.UIComponent;

    public class MSAAHelper {

        public var baseIndex:uint;
        use namespace mx_internal;

        public function MSAAHelper(item:*, count:uint):void {

            // Create the tab order
            this.baseIndex = count;
            checkChildren(item);
            //Alert.show("tabIndex is DONE!!");

            // Enable Flash to connect to a screen-reader (2 second delay)
            //setTimeout(updateReader, 2000);
        }

        private function updateReader():void {
            // Detect if a screen reader is enabled
            if (Capabilities.hasAccessibility) {
			
                // Refresh the MSAA data
                Accessibility.updateProperties();
            }
        }

        private function checkChildren(item:*):void {

            var filter:DropShadowFilter = new DropShadowFilter();
            filter.color = 0xFFFF00;

            for (var i:uint = 0; i < item.numChildren; i++) {
                try {
                    var obj:* = item.getChildAt(i);

                    if (obj is Container) {
                        checkChildren(obj);
                    } else {

                        // Provide a new tab index
                        InteractiveObject(obj).tabIndex = baseIndex;
                        //InteractiveObject(obj).filters = [ filter ];
                        baseIndex++;

                    }
                } catch (e:Error) {
                	trace("MSAA Error: "+e);
                }
            }

        }

    }

}