////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.core
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.IOErrorEvent;
    import flash.system.ApplicationDomain;
    import flash.utils.getQualifiedClassName;

    import org.apache.flex.events.Event;
    import org.apache.flex.utils.MXMLDataInterpreter;

    //--------------------------------------
    //  Events
    //--------------------------------------

    /**
     *  Dispatched at startup. Attributes and sub-instances of
     *  the MXML document have been created and assigned.
     *  The component lifecycle is different
     *  than the Flex SDK.  There is no creationComplete event.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    [Event(name="initialize", type="org.apache.flex.events.Event")]

    /**
     *  Dispatched at startup after the initial view has been
     *  put on the display list.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    [Event(name="viewChanged", type="org.apache.flex.events.Event")]

    /**
     *  The Application class is the main class and entry point for a FlexJS
     *  application.  This Application class is different than the
     *  Flex SDK's mx:Application or spark:Application in that it does not contain
     *  user interface elements.  Those UI elements go in the views.  This
     *  Application class expects there to be a main model, a controller, and
     *  an initial view.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    public class Application extends Sprite implements IStrand, IFlexInfo, IParent
    {
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function Application()
        {
            super();
			if (stage)
			{
				stage.align = StageAlign.TOP_LEFT;
				stage.scaleMode = StageScaleMode.NO_SCALE;
			}

            loaderInfo.addEventListener(flash.events.Event.INIT, initHandler);
        }

        /**
         *  The document property is used to provide
         *  a property lookup context for non-display objects.
         *  For Application, it points to itself.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var document:Object = this;

        private function initHandler(event:flash.events.Event):void
        {
            ValuesManager.valuesImpl = valuesImpl;
            ValuesManager.valuesImpl.init(this);

            dispatchEvent(new Event("initialize"));

            initialView.applicationModel =  model;
    	    this.addElement(initialView);
    	    dispatchEvent(new Event("viewChanged"));
            dispatchEvent(new Event("applicationComplete"));
        }

        /**
         *  The org.apache.flex.core.IValuesImpl that will
         *  determine the default values and other values
         *  for the application.  The most common choice
         *  is org.apache.flex.core.SimpleCSSValuesImpl.
         *
         *  @see org.apache.flex.core.SimpleCSSValuesImpl
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var valuesImpl:IValuesImpl;

        /**
         *  The initial view.
         *
         *  @see org.apache.flex.core.ViewBase
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var initialView:ViewBase;

        /**
         *  The data model (for the initial view).
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var model:Object;

        /**
         *  The controller.  The controller typically watches
         *  the UI for events and updates the model accordingly.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var controller:Object;

        /**
         *  An array of data that describes the MXML attributes
         *  and tags in an MXML document.  This data is usually
         *  decoded by an MXMLDataInterpreter
         *
         *  @see org.apache.flex.utils.MXMLDataInterpreter
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get MXMLDescriptor():Array
        {
            return null;
        }

        /**
         *  An method called by the compiler's generated
         *  code to kick off the setting of MXML attribute
         *  values and instantiation of child tags.
         *
         *  The call has to be made in the generated code
         *  in order to ensure that the constructors have
         *  completed first.
         *
         *  @param data The encoded data representing the
         *  MXML attributes.
         *
         *  @see org.apache.flex.utils.MXMLDataInterpreter
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
    	public function generateMXMLAttributes(data:Array):void
        {
			MXMLDataInterpreter.generateMXMLProperties(this, data);
        }

        /**
         *  The array property that is used to add additional
         *  beads to an MXML tag.  From ActionScript, just
         *  call addBead directly.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var beads:Array;

        private var _beads:Vector.<IBead>;

        /**
         *  @copy org.apache.flex.core.IStrand#addBead()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addBead(bead:IBead):void
        {
            if (!_beads)
                _beads = new Vector.<IBead>;
            _beads.push(bead);
            bead.strand = this;
        }

        /**
         *  @copy org.apache.flex.core.IStrand#getBeadByType()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function getBeadByType(classOrInterface:Class):IBead
        {
            for each (var bead:IBead in _beads)
            {
                if (bead is classOrInterface)
                    return bead;
            }
            return null;
        }

        /**
         *  @copy org.apache.flex.core.IStrand#removeBead()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function removeBead(value:IBead):IBead
        {
            var n:int = _beads.length;
            for (var i:int = 0; i < n; i++)
            {
                var bead:IBead = _beads[i];
                if (bead == value)
                {
                    _beads.splice(i, 1);
                    return bead;
                }
            }
            return null;
        }

        private var _info:Object;

        /**
         *  An Object containing information generated
         *  by the compiler that is useful at startup time.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function info():Object
        {
            if (!_info)
            {
                var mainClassName:String = getQualifiedClassName(this);
                var initClassName:String = "_" + mainClassName + "_FlexInit";
                var c:Class = ApplicationDomain.currentDomain.getDefinition(initClassName) as Class;
                _info = c.info();
            }
            return _info;
        }

        /**
         *  @copy org.apache.flex.core.IParent#addElement()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addElement(c:Object):void
        {
            if (c is IUIBase)
            {
                addChild(IUIBase(c).element as DisplayObject);
                IUIBase(c).addedToParent();
            }
            else
                addChild(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#addElementAt()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addElementAt(c:Object, index:int):void
        {
            if (c is IUIBase)
            {
                addChildAt(IUIBase(c).element as DisplayObject, index);
                IUIBase(c).addedToParent();
            }
            else
                addChildAt(c as DisplayObject, index);
        }

        /**
         *  @copy org.apache.flex.core.IParent#getElementIndex()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function getElementIndex(c:Object):int
        {
            if (c is IUIBase)
                return getChildIndex(IUIBase(c).element as DisplayObject);

            return getChildIndex(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#removeElement()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function removeElement(c:Object):void
        {
            if (c is IUIBase)
            {
                removeChild(IUIBase(c).element as DisplayObject);
            }
            else
                removeChild(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#numElements
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get numElements():int
        {
            return numChildren;
        }
    }
}

////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.core
{
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.IOErrorEvent;
    import flash.system.ApplicationDomain;
    import flash.utils.getQualifiedClassName;

    import org.apache.flex.events.Event;
    import org.apache.flex.utils.MXMLDataInterpreter;

    //--------------------------------------
    //  Events
    //--------------------------------------

    /**
     *  Dispatched at startup. Attributes and sub-instances of
     *  the MXML document have been created and assigned.
     *  The component lifecycle is different
     *  than the Flex SDK.  There is no creationComplete event.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    [Event(name="initialize", type="org.apache.flex.events.Event")]

    /**
     *  Dispatched at startup after the initial view has been
     *  put on the display list.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    [Event(name="viewChanged", type="org.apache.flex.events.Event")]

    /**
     *  Dispatched at startup after the initial view has been
     *  put on the display list.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    [Event(name="applicationComplete", type="org.apache.flex.events.Event")]

    /**
     *  The Application class is the main class and entry point for a FlexJS
     *  application.  This Application class is different than the
     *  Flex SDK's mx:Application or spark:Application in that it does not contain
     *  user interface elements.  Those UI elements go in the views.  This
     *  Application class expects there to be a main model, a controller, and
     *  an initial view.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
    public class Application extends Sprite implements IStrand, IFlexInfo, IParent
    {
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function Application()
        {
            super();
			if (stage)
			{
				stage.align = StageAlign.TOP_LEFT;
				stage.scaleMode = StageScaleMode.NO_SCALE;
			}

            loaderInfo.addEventListener(flash.events.Event.INIT, initHandler);
        }

        /**
         *  The document property is used to provide
         *  a property lookup context for non-display objects.
         *  For Application, it points to itself.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var document:Object = this;

        private function initHandler(event:flash.events.Event):void
        {
            ValuesManager.valuesImpl = valuesImpl;
            ValuesManager.valuesImpl.init(this);

            dispatchEvent(new Event("initialize"));

            if (initialView)
            {
                initialView.applicationModel =  model;
        	    this.addElement(initialView);
                dispatchEvent(new Event("viewChanged"));
            }
            dispatchEvent(new Event("applicationComplete"));
        }

        /**
         *  The org.apache.flex.core.IValuesImpl that will
         *  determine the default values and other values
         *  for the application.  The most common choice
         *  is org.apache.flex.core.SimpleCSSValuesImpl.
         *
         *  @see org.apache.flex.core.SimpleCSSValuesImpl
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var valuesImpl:IValuesImpl;

        /**
         *  The initial view.
         *
         *  @see org.apache.flex.core.ViewBase
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var initialView:ViewBase;

        /**
         *  The data model (for the initial view).
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var model:Object;

        /**
         *  The controller.  The controller typically watches
         *  the UI for events and updates the model accordingly.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var controller:Object;

        /**
         *  An array of data that describes the MXML attributes
         *  and tags in an MXML document.  This data is usually
         *  decoded by an MXMLDataInterpreter
         *
         *  @see org.apache.flex.utils.MXMLDataInterpreter
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get MXMLDescriptor():Array
        {
            return null;
        }

        /**
         *  An method called by the compiler's generated
         *  code to kick off the setting of MXML attribute
         *  values and instantiation of child tags.
         *
         *  The call has to be made in the generated code
         *  in order to ensure that the constructors have
         *  completed first.
         *
         *  @param data The encoded data representing the
         *  MXML attributes.
         *
         *  @see org.apache.flex.utils.MXMLDataInterpreter
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
    	public function generateMXMLAttributes(data:Array):void
        {
			MXMLDataInterpreter.generateMXMLProperties(this, data);
        }

        /**
         *  The array property that is used to add additional
         *  beads to an MXML tag.  From ActionScript, just
         *  call addBead directly.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var beads:Array;

        private var _beads:Vector.<IBead>;

        /**
         *  @copy org.apache.flex.core.IStrand#addBead()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addBead(bead:IBead):void
        {
            if (!_beads)
                _beads = new Vector.<IBead>;
            _beads.push(bead);
            bead.strand = this;
        }

        /**
         *  @copy org.apache.flex.core.IStrand#getBeadByType()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function getBeadByType(classOrInterface:Class):IBead
        {
            for each (var bead:IBead in _beads)
            {
                if (bead is classOrInterface)
                    return bead;
            }
            return null;
        }

        /**
         *  @copy org.apache.flex.core.IStrand#removeBead()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function removeBead(value:IBead):IBead
        {
            var n:int = _beads.length;
            for (var i:int = 0; i < n; i++)
            {
                var bead:IBead = _beads[i];
                if (bead == value)
                {
                    _beads.splice(i, 1);
                    return bead;
                }
            }
            return null;
        }

        private var _info:Object;

        /**
         *  An Object containing information generated
         *  by the compiler that is useful at startup time.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function info():Object
        {
            if (!_info)
            {
                var mainClassName:String = getQualifiedClassName(this);
                var initClassName:String = "_" + mainClassName + "_FlexInit";
                var c:Class = ApplicationDomain.currentDomain.getDefinition(initClassName) as Class;
                _info = c.info();
            }
            return _info;
        }

        /**
         *  @copy org.apache.flex.core.IParent#addElement()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addElement(c:Object):void
        {
            if (c is IUIBase)
            {
                addChild(IUIBase(c).element as DisplayObject);
                IUIBase(c).addedToParent();
            }
            else
                addChild(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#addElementAt()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function addElementAt(c:Object, index:int):void
        {
            if (c is IUIBase)
            {
                addChildAt(IUIBase(c).element as DisplayObject, index);
                IUIBase(c).addedToParent();
            }
            else
                addChildAt(c as DisplayObject, index);
        }

        /**
         *  @copy org.apache.flex.core.IParent#getElementIndex()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function getElementIndex(c:Object):int
        {
            if (c is IUIBase)
                return getChildIndex(IUIBase(c).element as DisplayObject);

            return getChildIndex(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#removeElement()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function removeElement(c:Object):void
        {
            if (c is IUIBase)
            {
                removeChild(IUIBase(c).element as DisplayObject);
            }
            else
                removeChild(c as DisplayObject);
        }

        /**
         *  @copy org.apache.flex.core.IParent#numElements
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get numElements():int
        {
            return numChildren;
        }
    }
}

make application a little more tolerant so it can be used in flexunit tests


/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 package org.mangui.osmf.plugins.traits {
    import org.mangui.hls.HLS;
	import org.mangui.hls.constant.HLSPlayStates;
    import org.mangui.hls.event.HLSEvent;
    import org.osmf.traits.PlayState;
    import org.osmf.traits.PlayTrait;

    CONFIG::LOGGING {
    import org.mangui.hls.utils.Log;
    }

    public class HLSPlayTrait extends PlayTrait
    {
        private var _hls : HLS;

        private var streamStarted : Boolean = false;

        public function HLSPlayTrait(hls : HLS)
        {
            CONFIG::LOGGING {
            Log.debug("HLSPlayTrait()");
            }
            super();
            _hls = hls;
			_hls.addEventListener(HLSEvent.PLAYBACK_STATE, _stateChangedHandler);
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _playbackComplete);
        }

        override public function dispose() : void
        {
            CONFIG::LOGGING {
            Log.debug("HLSPlayTrait:dispose");
            }
			_hls.removeEventListener(HLSEvent.PLAYBACK_STATE, _stateChangedHandler);
            _hls.removeEventListener(HLSEvent.PLAYBACK_COMPLETE, _playbackComplete);
            super.dispose();
        }

		/** state changed handler **/
		private function _stateChangedHandler(event:HLSEvent):void
		{
			switch (event.state)
			{
				case HLSPlayStates.PLAYING:
					CONFIG::LOGGING
				{
					Log.debug("HLSPlayTrait:_stateChangedHandler:setBuffering(true)");
				}
					if (!streamStarted)
					{
                        streamStarted = true;
						play();
					}
				default:
            }
        }

        override protected function playStateChangeStart(newPlayState:String):void
        {
            CONFIG::LOGGING
            {
                Log.info("HLSPlayTrait:playStateChangeStart:" + newPlayState);
            }
            switch (newPlayState)
            {
                case PlayState.PLAYING:
                    if (!streamStarted)
                    {
                        _hls.stream.play();
                        streamStarted = true;
                    }
                    else
                    {
                        _hls.stream.resume();

                    }
                    break;
                case PlayState.PAUSED:
                    _hls.stream.pause();
                    break;
                case PlayState.STOPPED:
                    streamStarted = false;
                    _hls.stream.close();
                    break;
            }
        }

        /** playback complete handler **/
        private function _playbackComplete(event : HLSEvent) : void {
            stop();
        }
    }
}

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 package org.mangui.osmf.plugins.traits {
    import org.mangui.hls.HLS;
	import org.mangui.hls.constant.HLSPlayStates;
    import org.mangui.hls.event.HLSEvent;
    import org.osmf.traits.PlayState;
    import org.osmf.traits.PlayTrait;

    CONFIG::LOGGING {
    import org.mangui.hls.utils.Log;
    }

    public class HLSPlayTrait extends PlayTrait
    {
        private var _hls : HLS;

        private var streamStarted : Boolean = false;

        public function HLSPlayTrait(hls : HLS)
        {
            CONFIG::LOGGING {
            Log.debug("HLSPlayTrait()");
            }
            super();
            _hls = hls;
			_hls.addEventListener(HLSEvent.PLAYBACK_STATE, _stateChangedHandler);
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _playbackComplete);
        }

        override public function dispose() : void
        {
            CONFIG::LOGGING {
            Log.debug("HLSPlayTrait:dispose");
            }
			_hls.removeEventListener(HLSEvent.PLAYBACK_STATE, _stateChangedHandler);
            _hls.removeEventListener(HLSEvent.PLAYBACK_COMPLETE, _playbackComplete);
            super.dispose();
        }

        override protected function playStateChangeStart(newPlayState:String):void
        {
            CONFIG::LOGGING
            {
                Log.info("HLSPlayTrait:playStateChangeStart:" + newPlayState);
            }
            switch (newPlayState)
            {
                case PlayState.PLAYING:
                    if (!streamStarted)
                    {
                        _hls.stream.play();
                        streamStarted = true;
                    }
                    else
                    {
                        _hls.stream.resume();

                    }
                    break;
                case PlayState.PAUSED:
                    _hls.stream.pause();
                    break;
                case PlayState.STOPPED:
                    streamStarted = false;
                    _hls.stream.close();
                    break;
            }
        }

        /** state changed handler **/
        private function _stateChangedHandler(event:HLSEvent):void
        {
            switch (event.state)
            {
                case HLSPlayStates.PLAYING:
                CONFIG::LOGGING
                {
                    Log.debug("HLSPlayTrait:_stateChangedHandler:setBuffering(true)");
                }
                    if (!streamStarted)
                    {
                        streamStarted = true;
                        play();
                    }
                default:
            }
        }

        /** playback complete handler **/
        private function _playbackComplete(event : HLSEvent) : void {
            stop();
        }
    }
}

support playback even after playbak finished


package Modules {
	import Components.Port;
	import Values.Value;
	import Values.BooleanValue;
	/**
	 * ...
	 * @author Nicholas "PleasingFungus" Feinberg
	 */
	public class And extends Module {

		private var width:int;
		public function And(X:int, Y:int, Width:int = 2) {
			super(X, Y, "And", Module.CAT_LOGIC, Width, 1, 0);
			width = Width;
			configuration = new Configuration(new Range(2, 8, Width));
			configurableInPlace = false;
			delay = Math.ceil(Math.log(Width) / Math.log(2));
		}

		protected function resetPorts():void {
			outputs = new Vector.<Port>;
			outputs.push(new Port(true, this));
		}

		override public function renderDetails():String {
			var out:String = "And\n\n";
			for each (var input:Port in inputs)
				out += input.getValue() + ',';
			return out.slice(0, out.length - 1);
		}

		override public function getDescription():String {
			return "Outputs "+BooleanValue.FALSE+" if any input is "+BooleanValue.FALSE+", else "+BooleanValue.TRUE+"."
		}

		override protected function getSaveValues():Array {
			var values:Array = super.getSaveValues();
			values.push(width);
			return values;
		}

		override public function drive(port:Port):Value {
			for each (var inputPort:Port in inputs) {
				var inputValue:Value = inputPort.getValue();
				if (inputValue.unknown || inputValue.unpowered)
					return inputValue;
				if (!BooleanValue.fromValue(inputValue).boolValue)
					return BooleanValue.FALSE;
			}
			return BooleanValue.TRUE;
		}

	}

}

package Modules {
	import Components.Port;
	import Layouts.PortLayout;
	import Layouts.InternalLayout;
	import Layouts.Nodes.TallNode;
	import Values.Value;
	import Values.BooleanValue;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Nicholas "PleasingFungus" Feinberg
	 */
	public class And extends Module {

		private var width:int;
		public function And(X:int, Y:int, Width:int = 2) {
			super(X, Y, "And", Module.CAT_LOGIC, Width, 1, 0);
			width = Width;
			configuration = new Configuration(new Range(2, 8, Width));
			configurableInPlace = false;
			delay = Math.ceil(Math.log(Width) / Math.log(2));
		}

		override protected function generateInternalLayout():InternalLayout {
			var ports:Array = [];
			for each (var portLayout:PortLayout in layout.ports)
				ports.push(portLayout);

			var outport:PortLayout = layout.ports[layout.ports.length - 1];

			return new InternalLayout([new TallNode(this, new Point(outport.offset.x - layout.dim.x / 2 - 1 / 2, outport.offset.y),
														ports, [], function getValue():Value { return drive(outputs[0]); }, "All" )]);
		}

		protected function resetPorts():void {
			outputs = new Vector.<Port>;
			outputs.push(new Port(true, this));
		}

		override public function renderDetails():String {
			var out:String = "And\n\n";
			for each (var input:Port in inputs)
				out += input.getValue() + ',';
			return out.slice(0, out.length - 1);
		}

		override public function getDescription():String {
			return "Outputs "+BooleanValue.FALSE+" if any input is "+BooleanValue.FALSE+", else "+BooleanValue.TRUE+"."
		}

		override protected function getSaveValues():Array {
			var values:Array = super.getSaveValues();
			values.push(width);
			return values;
		}

		override public function drive(port:Port):Value {
			for each (var inputPort:Port in inputs) {
				var inputValue:Value = inputPort.getValue();
				if (inputValue.unknown || inputValue.unpowered)
					return inputValue;
				if (!BooleanValue.fromValue(inputValue).boolValue)
					return BooleanValue.FALSE;
			}
			return BooleanValue.TRUE;
		}

	}

}

ADD internals

ADD internals


/*
Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package org.windmill {
  import flash.display.Loader;
  import flash.net.URLRequest;
  import flash.events.Event;
  import flash.system.ApplicationDomain;
  import flash.system.LoaderContext;

  public class WMBootstrap {
    public static var windmillLibPath:String = '/flash/org/windmill/Windmill.swf';
    public static function init(context:*):void {
      var loader:Loader = new Loader();
      var url:String = WMBootstrap.windmillLibPath;
      var req:URLRequest = new URLRequest(url);
      var con:LoaderContext = new LoaderContext(false,
          ApplicationDomain.currentDomain);
      loader.contentLoaderInfo.addEventListener(
          Event.COMPLETE, function ():void {
        var Windmill:*;
        Windmill = ApplicationDomain.currentDomain.getDefinition(
            "org.windmill.Windmill") as Class;
        Windmill.init({ context: context });
      });
      loader.load(req, con);
    }
  }
}

/*
Copyright 2009, Matthew Eernisse (mde@fleegix.org) and Slide, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package org.windmill {
  import flash.display.Loader;
  import flash.net.URLRequest;
  import flash.events.Event;
  import flash.system.ApplicationDomain;
  import flash.system.SecurityDomain;
  import flash.system.LoaderContext;

  public class WMBootstrap {
    public static var windmillLibPath:String = '/flash/org/windmill/Windmill.swf';
    public static var wm:*;
    public static function init(context:*, domains:* = null):void {
      var loader:Loader = new Loader();
      var url:String = WMBootstrap.windmillLibPath;
      var req:URLRequest = new URLRequest(url);
      var con:LoaderContext = new LoaderContext(false,
          ApplicationDomain.currentDomain,
          SecurityDomain.currentDomain);
      loader.contentLoaderInfo.addEventListener(
          Event.COMPLETE, function ():void {
        wm = ApplicationDomain.currentDomain.getDefinition(
            "org.windmill.Windmill") as Class;
        wm.init({ context: context, domains: domains });
      });
      loader.load(req, con);
    }
  }
}

Load Windmill.swf in the correct SecurityDomain, and pass script-access domains up to Windmill so it can give access to the API.


////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
package com.esri.builder.components.serviceBrowser.supportClasses
{

import com.esri.ags.tasks.JSONTask;
import com.esri.builder.components.serviceBrowser.filters.INodeFilter;
import com.esri.builder.components.serviceBrowser.nodes.FolderNode;
import com.esri.builder.components.serviceBrowser.nodes.GPTaskNode;
import com.esri.builder.components.serviceBrowser.nodes.LayerNode;
import com.esri.builder.components.serviceBrowser.nodes.RouteLayerNode;
import com.esri.builder.components.serviceBrowser.nodes.ServerNode;
import com.esri.builder.components.serviceBrowser.nodes.ServiceDirectoryNode;
import com.esri.builder.components.serviceBrowser.nodes.TableNode;

import flash.events.EventDispatcher;
import flash.net.URLVariables;

import mx.rpc.AsyncResponder;
import mx.rpc.Fault;
import mx.rpc.events.FaultEvent;

public class ServiceDirectoryNodeFetcher extends EventDispatcher
{
    private const DEFAULT_TIMEOUT_IN_SECONDS:int = 10;

    public var token:String;
    public var requestTimeout:int;

    private var nodes:Array;
    private var nodeFilter:INodeFilter;
    private var totalLayerNodesToLoad:int;
    private var layerNodesToLoad:Array;
    private var totalTableNodesToLoad:int;
    private var tableNodesToLoad:Array;

    private var allLayersProcessed:Boolean = true;
    private var allTablesProcessed:Boolean = true;

    public function fetch(url:String, nodeFilter:INodeFilter, parent:ServiceDirectoryNode):void
    {
        this.nodeFilter = nodeFilter;

        const urlVars:URLVariables = new URLVariables();
        urlVars.f = "json";

        const nodeInfoRequest:JSONTask = new JSONTask(url);
        nodeInfoRequest.requestTimeout = getValidRequestTimeout();
        nodeInfoRequest.token = token;
        nodeInfoRequest.execute(urlVars,
                                new AsyncResponder(nodeInfoRequest_resultHandler,
                                                   nodeInfoRequest_faultHandler,
                                                   parent));
    }

    private function getValidRequestTimeout():int
    {
        const isRequestTimeoutValid:Boolean = !isNaN(requestTimeout) && requestTimeout > -1;
        return isRequestTimeoutValid ? requestTimeout : DEFAULT_TIMEOUT_IN_SECONDS;
    }

    private function nodeInfoRequest_resultHandler(metadata:Object, parent:ServiceDirectoryNode):void
    {
        nodes = [];

        for each (var folderName:String in metadata.folders)
        {
            const folderNode:FolderNode =
                ServiceDirectoryNodeCreator.createFolderNode(parent, folderName);
            if (nodeFilter.isApplicable(folderNode))
            {
                folderNode.token = token;
                nodes.push(folderNode);
            }
        }

        for each (var taskName:String in metadata.tasks)
        {
            const taskNode:GPTaskNode =
                ServiceDirectoryNodeCreator.createGPTaskNode(parent, taskName);
            if (nodeFilter.isApplicable(taskNode))
            {
                taskNode.token = token;
                nodes.push(taskNode);
            }
        }

        for each (var service:Object in metadata.services)
        {
            const serverNode:ServerNode =
                ServiceDirectoryNodeCreator.createServerNode(parent, service);
            if (nodeFilter.isApplicable(serverNode))
            {
                serverNode.isBranch = nodeFilter.serverChildrenAllowed;
                serverNode.token = token;
                nodes.push(serverNode);
            }
        }

        for each (var routeLayerName:String in metadata.routeLayers)
        {
            const routeNode:RouteLayerNode =
                ServiceDirectoryNodeCreator.createRouteNode(parent, routeLayerName);
            if (nodeFilter.isApplicable(routeNode))
            {
                routeNode.token = token;
                nodes.push(routeNode);
            }
        }

        layerNodesToLoad = [];
        for each (var layer:Object in metadata.layers)
        {
            const layerNode:LayerNode =
                ServiceDirectoryNodeCreator.createLayerNode(parent, layer);
            if (layerNode)
            {
                layerNode.token = token;
                layerNodesToLoad.push(layerNode);
            }
        }

        tableNodesToLoad = [];
        for each (var table:Object in metadata.tables)
        {
            const tableNode:TableNode =
                ServiceDirectoryNodeCreator.createTableNode(parent, table);
            if (tableNode)
            {
                tableNode.token = token;
                tableNodesToLoad.push(tableNode);
            }
        }

        if (layerNodesToLoad.length > 0)
        {
            allLayersProcessed = false;
            fetchLayerNodeInfo();
        }
        if (tableNodesToLoad.length > 0)
        {
            allTablesProcessed = false;
            fetchTableNodeInfo();
        }

        if (layerNodesToLoad.length == 0 && tableNodesToLoad.length == 0)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function fetchLayerNodeInfo():void
    {
        totalLayerNodesToLoad = layerNodesToLoad.length;
        var urlVars:URLVariables;
        var layerInfoRequest:JSONTask;
        for each (var layerNode:LayerNode in layerNodesToLoad)
        {
            urlVars = new URLVariables();
            urlVars.f = "json";
            layerInfoRequest = new JSONTask(layerNode.internalURL);
            layerInfoRequest.requestTimeout = getValidRequestTimeout();
            layerInfoRequest.token = token;
            layerInfoRequest.execute(urlVars,
                                     new AsyncResponder(layerInfoRequest_resultHandler,
                                                        layerNodeInfoRequest_faultHandler,
                                                        layerNode));
        }
    }

    private function fetchTableNodeInfo():void
    {
        totalTableNodesToLoad = tableNodesToLoad.length;
        var urlVars:URLVariables;
        var tableInfoRequest:JSONTask;
        for each (var tableNode:TableNode in tableNodesToLoad)
        {
            urlVars = new URLVariables();
            urlVars.f = "json";
            tableInfoRequest = new JSONTask(tableNode.internalURL);
            tableInfoRequest.requestTimeout = getValidRequestTimeout();
            tableInfoRequest.token = token;
            tableInfoRequest.execute(urlVars,
                                     new AsyncResponder(tableInfoRequest_resultHandler,
                                                        tableNodeInfoRequest_faultHandler,
                                                        tableNode));
        }
    }

    private function layerNodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        layerProcessed();
    }

    private function tableNodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        tableProcessed();
    }

    private function layerProcessed():void
    {
        totalLayerNodesToLoad--;
        if (totalLayerNodesToLoad == 0)
        {
            addProcessedLayerNodesAndDispatchFetchComplete();
        }
    }

    private function tableProcessed():void
    {
        totalTableNodesToLoad--;
        if (totalTableNodesToLoad == 0)
        {
            addProcessedTableNodesAndDispatchFetchComplete();
        }
    }

    private function addProcessedLayerNodesAndDispatchFetchComplete():void
    {
        for each (var layerNode:LayerNode in layerNodesToLoad)
        {
            if (nodeFilter.isApplicable(layerNode))
            {
                nodes.push(layerNode);
            }
        }
        allLayersProcessed = true;
        if (allLayersProcessed && allTablesProcessed)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function addProcessedTableNodesAndDispatchFetchComplete():void
    {
        for each (var tableNode:TableNode in tableNodesToLoad)
        {
            if (nodeFilter.isApplicable(tableNode))
            {
                nodes.push(tableNode);
            }
        }
        allTablesProcessed = true;
        if (allLayersProcessed && allTablesProcessed)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function dispatchNodeFetchComplete():void
    {
        dispatchEvent(
            new ServiceDirectoryNodeFetchEvent(ServiceDirectoryNodeFetchEvent.NODE_FETCH_COMPLETE,
                                               nodes));
    }

    private function layerInfoRequest_resultHandler(metadata:Object, layerNode:LayerNode):void
    {
        layerNode.metadata = metadata;
        layerProcessed();
    }

    private function tableInfoRequest_resultHandler(metadata:Object, tableNode:TableNode):void
    {
        tableNode.metadata = metadata;
        tableProcessed();
    }

    private function nodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        dispatchEvent(new FaultEvent(FaultEvent.FAULT, false, false, fault));
    }
}
}

////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
package com.esri.builder.components.serviceBrowser.supportClasses
{

import com.esri.ags.tasks.JSONTask;
import com.esri.builder.components.serviceBrowser.filters.INodeFilter;
import com.esri.builder.components.serviceBrowser.nodes.FolderNode;
import com.esri.builder.components.serviceBrowser.nodes.GPTaskNode;
import com.esri.builder.components.serviceBrowser.nodes.LayerNode;
import com.esri.builder.components.serviceBrowser.nodes.QueryableNode;
import com.esri.builder.components.serviceBrowser.nodes.RouteLayerNode;
import com.esri.builder.components.serviceBrowser.nodes.ServerNode;
import com.esri.builder.components.serviceBrowser.nodes.ServiceDirectoryNode;
import com.esri.builder.components.serviceBrowser.nodes.TableNode;

import flash.events.EventDispatcher;
import flash.net.URLVariables;

import mx.rpc.AsyncResponder;
import mx.rpc.Fault;
import mx.rpc.events.FaultEvent;

public class ServiceDirectoryNodeFetcher extends EventDispatcher
{
    private const DEFAULT_TIMEOUT_IN_SECONDS:int = 10;

    public var token:String;
    public var requestTimeout:int;

    private var nodes:Array;
    private var nodeFilter:INodeFilter;
    private var totalNodesToLoad:int;
    private var nodesToLoad:Array;

    private var allNodesProcessed:Boolean = true;

    public function fetch(url:String, nodeFilter:INodeFilter, parent:ServiceDirectoryNode):void
    {
        this.nodeFilter = nodeFilter;

        const urlVars:URLVariables = new URLVariables();
        urlVars.f = "json";

        const nodeInfoRequest:JSONTask = new JSONTask(url);
        nodeInfoRequest.requestTimeout = getValidRequestTimeout();
        nodeInfoRequest.token = token;
        nodeInfoRequest.execute(urlVars,
                                new AsyncResponder(nodeInfoRequest_resultHandler,
                                                   nodeInfoRequest_faultHandler,
                                                   parent));
    }

    private function getValidRequestTimeout():int
    {
        const isRequestTimeoutValid:Boolean = !isNaN(requestTimeout) && requestTimeout > -1;
        return isRequestTimeoutValid ? requestTimeout : DEFAULT_TIMEOUT_IN_SECONDS;
    }

    private function nodeInfoRequest_resultHandler(metadata:Object, parent:ServiceDirectoryNode):void
    {
        nodes = [];

        for each (var folderName:String in metadata.folders)
        {
            const folderNode:FolderNode =
                ServiceDirectoryNodeCreator.createFolderNode(parent, folderName);
            if (nodeFilter.isApplicable(folderNode))
            {
                folderNode.token = token;
                nodes.push(folderNode);
            }
        }

        for each (var taskName:String in metadata.tasks)
        {
            const taskNode:GPTaskNode =
                ServiceDirectoryNodeCreator.createGPTaskNode(parent, taskName);
            if (nodeFilter.isApplicable(taskNode))
            {
                taskNode.token = token;
                nodes.push(taskNode);
            }
        }

        for each (var service:Object in metadata.services)
        {
            const serverNode:ServerNode =
                ServiceDirectoryNodeCreator.createServerNode(parent, service);
            if (nodeFilter.isApplicable(serverNode))
            {
                serverNode.isBranch = nodeFilter.serverChildrenAllowed;
                serverNode.token = token;
                nodes.push(serverNode);
            }
        }

        for each (var routeLayerName:String in metadata.routeLayers)
        {
            const routeNode:RouteLayerNode =
                ServiceDirectoryNodeCreator.createRouteNode(parent, routeLayerName);
            if (nodeFilter.isApplicable(routeNode))
            {
                routeNode.token = token;
                nodes.push(routeNode);
            }
        }

        nodesToLoad = [];
        for each (var layer:Object in metadata.layers)
        {
            const layerNode:LayerNode =
                ServiceDirectoryNodeCreator.createLayerNode(parent, layer);
            if (layerNode)
            {
                layerNode.token = token;
                nodesToLoad.push(layerNode);
            }
        }

        for each (var table:Object in metadata.tables)
        {
            const tableNode:TableNode =
                ServiceDirectoryNodeCreator.createTableNode(parent, table);
            if (tableNode)
            {
                tableNode.token = token;
                nodesToLoad.push(tableNode);
            }
        }

        if (nodesToLoad.length > 0)
        {
            allNodesProcessed = false;
            fetchQueryableNodeInfo();
        }

        if (nodesToLoad.length == 0)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function fetchQueryableNodeInfo():void
    {
        totalNodesToLoad = nodesToLoad.length;
        var urlVars:URLVariables;
        var layerInfoRequest:JSONTask;
        for each (var queryableNode:QueryableNode in nodesToLoad)
        {
            urlVars = new URLVariables();
            urlVars.f = "json";
            layerInfoRequest = new JSONTask(queryableNode.internalURL);
            layerInfoRequest.requestTimeout = getValidRequestTimeout();
            layerInfoRequest.token = token;
            layerInfoRequest.execute(urlVars,
                                     new AsyncResponder(queryableNodeInfoRequest_resultHandler,
                                                        queryableNodeInfoRequest_faultHandler,
                                                        queryableNode));
        }
    }

    private function queryableNodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        nodeProcessed();
    }

    private function nodeProcessed():void
    {
        totalNodesToLoad--;
        if (totalNodesToLoad == 0)
        {
            addProcessedNodesAndDispatchFetchComplete();
        }
    }

    private function addProcessedNodesAndDispatchFetchComplete():void
    {
        for each (var queryableNode:QueryableNode in nodesToLoad)
        {
            if (nodeFilter.isApplicable(queryableNode))
            {
                nodes.push(queryableNode);
            }
        }
        allNodesProcessed = true;
        if (allNodesProcessed)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function dispatchNodeFetchComplete():void
    {
        dispatchEvent(
            new ServiceDirectoryNodeFetchEvent(ServiceDirectoryNodeFetchEvent.NODE_FETCH_COMPLETE,
                                               nodes));
    }

    private function queryableNodeInfoRequest_resultHandler(metadata:Object, queryableNode:QueryableNode):void
    {
        queryableNode.metadata = metadata;
        nodeProcessed();
    }

    private function nodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        dispatchEvent(new FaultEvent(FaultEvent.FAULT, false, false, fault));
    }
}
}

Simplify layer/table node info fetching.


/*
 * Copyright 2008 Adobe Systems Inc., 2008 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributor(s):
 *   Zwetan Kjukov <zwetan@gmail.com>.
 */

package com.google.analytics
{
    import com.google.analytics.utils.Version;

    public class API
    {

        /**
        * version of Google Analytics AS3 API
        *
        * note:
        * each components share the same code base and so the same version
        */
        public static var version:Version = new Version();
        include "version.properties"
        version.revision = "$Rev$ ".split( " " )[1];

    }
}

/*
 * Copyright 2008 Adobe Systems Inc., 2008 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Contributor(s):
 *   Zwetan Kjukov <zwetan@gmail.com>.
 */

package com.google.analytics
{
    import core.version;

    public class API
    {

        /**
        * version of Google Analytics AS3 API
        *
        * note:
        * each components share the same code base and so the same version
        */
        public static var version:core.version = new core.version();
        include "version.properties"
        version.revision = "$Rev$ ".split( " " )[1];

    }
}

replace utils Version class by uri.version class


/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirPushNotification {

	import flash.events.EventDispatcher;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;

    /**
     *
     */
    public class PushNotification extends EventDispatcher {

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									   PUBLIC API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

		public static const RECURRENCE_NONE:int = 0;
		public static const RECURRENCE_DAILY:int = 1;
		public static const RECURRENCE_WEEK:int = 2;
		public static const RECURRENCE_MONTH:int = 3;
		public static const RECURRENCE_YEAR:int = 4;

		public static const DEFAULT_LOCAL_NOTIFICATION_ID:int = 0;

        /**
         * If true, logs will be displayed at the ActionScript level.
         */
        public static var logEnabled:Boolean = false;

        /**
         *
         */
        public static function get isSupported():Boolean {
            return _isIOS() || _isAndroid();
        }

        /**
         *
         */
        public static function get instance():PushNotification {
            return _instance ? _instance : new PushNotification();
        }

        private function callContext(...args):*
        {
            var context: ExtensionContext = getContext();
            if(!context) {
                _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.")
                return null;
            }
            try {
                return context.call.apply(context, args);
            } catch (e: Error) {
                _log("ERROR", "Error calling extension context: " + e.message + " : " + e.getStackTrace());
            }
            return null;
        }

		/**
		 *  return true if notifs are enabled for this app in device settings
		 *  If iOS < 8 or android < 4.1 this isn't available, so will always return true.
		 */
		public function getNotificationsEnabled():void {

			if (!isSupported)
				return;

			callContext("getNotificationsEnabled");
		}

		/**
		 * Check if notificationChannel is enabled in Android notification settings
		 * @param channelId
		 * @return
		 */
		public function isNotificationChannelEnabled(channelId:String):Boolean {

			if (!isSupported)
				return false;

			if(_isIOS())
				return true;

			return callContext("checkNotificationChannelEnabled", channelId);
		}

		/**
		 * return true if OS permits sending user to settings (iOS 8, Android
		 */
		public function get canSendUserToSettings():Boolean {

			if (!isSupported)
				return false;

			return callContext("getCanSendUserToSettings");
		}

        /**
         *
         */
		public function openDeviceNotificationSettings(channelId:String = null):void {

			if(!channelId)
				channelId = "";

			if (isSupported)
                callContext("openDeviceNotificationSettings", channelId);
		}

        /**
		 * Needs Project id for Android Notifications.
		 * The project id is the one the developer used to register to gcm.
		 * @param projectId: project id to use
		 * @param iOSNotificationCategories: notification categories used on iOS (PushNotificationCategoryiOS)
		 */
		public function registerForPushNotification(projectId:String = null, iOSNotificationCategories:Array = null):void {

			if(!isSupported)
				return;

			if (_isAndroid())
                callContext("registerPush", projectId);
			else if(_isIOS())
				callContext("registerPush", iOSNotificationCategories != null ? JSON.stringify(iOSNotificationCategories) : null);
		}

        /**
         *
         * @param value
         */
		public function setBadgeNumberValue(value:int):void {

			if (isSupported)
                callContext("setBadgeNb", value);
		}

		/**
		 * Sends a local notification to the device.
		 * @param message   the local notification text displayed
		 * @param timestamp when the local notification should appear (in sec)
		 * @param title     (Android Only) Title of the local notification
		 * @param recurrenceType
         * @param notificationId
         * @param deepLinkPath
         * @param iconPath
         * @param groupId  used to group notifications together
         * @param categoryId  used to display custom summaries on iOS
         * @param makeSquare  used to display square icons on Android, will default to round
		 */
		public function sendLocalNotification(message:String,
                                              timestamp:int,
                                              title:String,
                                              recurrenceType:int = RECURRENCE_NONE,
											  notificationId:int = DEFAULT_LOCAL_NOTIFICATION_ID,
                                              deepLinkPath:String = null,
                                              iconPath:String = null,
                                              groupId:String = null,
											  categoryId:String = null,
											  makeSquare:Boolean = false
		):void {

			if (!isSupported)
				return;

			if(!iconPath)
				iconPath = "";

			if(!deepLinkPath)
				deepLinkPath = "";

			if(!groupId)
				groupId = "";

			if(!categoryId)
				categoryId = "";

			callContext("sendLocalNotification", message, timestamp, title, recurrenceType, notificationId, deepLinkPath, iconPath, groupId, categoryId, makeSquare);

		}

		/**
      	* Not implemented on Android for now.
      	* @param notificationId
	  	*/
	    public function cancelLocalNotification(notificationId:int = DEFAULT_LOCAL_NOTIFICATION_ID):void {

	       	if (isSupported) {

	         	if (notificationId == DEFAULT_LOCAL_NOTIFICATION_ID)
                    callContext("cancelLocalNotification");
	         	else
                    callContext("cancelLocalNotification", notificationId);
	       	}
	    }

        /**
         *
         */
		public function cancelAllLocalNotifications():void {

			if (isSupported)
                callContext("cancelAllLocalNotifications");
		}

        /**
         *
         * @param value
         */
		public function setIsAppInForeground(value:Boolean, appGroupId:String):void {

			if (isSupported)
                callContext("setIsAppInForeground", value, appGroupId);
		}

        /**
         *
         * @param listener
         */
		public function addListenerForStarterNotifications(listener:Function):void {

			if (isSupported) {

				this.addEventListener(PushNotificationEvent.APP_STARTING_FROM_NOTIFICATION_EVENT, listener);
                callContext("fetchStarterNotification");
			}
		}

		public function checkAppNotificationSettingsRequest():void {

			if (_isIOS()) {
				callContext("checkAppNotificationSettingsRequest");
			}
		}

        public function storeTrackingNotifUrl(url:String, appGroupId:String):void {

            if (isSupported)
                callContext("storeNotifTrackingInfo", url, appGroupId);
        }

		/**
		 * Create Android notification channel
		 * @param channelId
		 * @param channelName
		 * @param importance
		 * @param enableLights
		 * @param enableVibration
		 */
		public function createAndroidNotificationChannel(channelId:String, channelName:String, importance:int, enableLights:Boolean, enableVibration:Boolean):void {

			if (_isAndroid())
				callContext("createNotificationChannel", channelId, channelName, importance, enableLights, enableVibration);
		}

		// --------------------------------------------------------------------------------------//
        //																						 //
        // 									 	PRIVATE API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        private static const EXTENSION_ID:String = "com.freshplanet.ane.AirPushNotification";
        private static var _instance:PushNotification = null;

        /**
         * "private" singleton constructor
         */
        public function PushNotification() {

            super();

            if (_instance)
                throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");

            _instance = this;
        }

        private var __context:ExtensionContext;
        private function getContext():ExtensionContext
        {
            if (!__context) {
                __context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
                if (!__context) {
                    _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.");
                } else {
                    __context.addEventListener(StatusEvent.STATUS, _onStatus);
                }
            }
            return __context;
        }

        /**
         *
         * @param strings
         */
        private function _log(...strings):void {

            if (logEnabled) {

                strings.unshift(EXTENSION_ID);
                trace.apply(null, strings);
            }
        }

        /**
         *
         * @return  true if iOS
         */
        private static function _isIOS():Boolean {
			return Capabilities.manufacturer.indexOf("iOS") > -1 && Capabilities.os.indexOf("x86_64") < 0 && Capabilities.os.indexOf("i386") < 0;
        }

        /**
         *
         * @return  true if Android
         */
        private static function _isAndroid():Boolean {
            return Capabilities.manufacturer.indexOf("Android") > -1;
        }

        /**
         *
         * @param e
         */
        private function _onStatus(e:StatusEvent):void {

            var event:PushNotificationEvent = null;
            var data:String = e.level;

            switch (e.code) {

                case "TOKEN_SUCCESS":
                    event = new PushNotificationEvent(PushNotificationEvent.PERMISSION_GIVEN_WITH_TOKEN_EVENT);
                    event.token = e.level;
                    break;

                case "TOKEN_FAIL":
                    event = new PushNotificationEvent(PushNotificationEvent.PERMISSION_REFUSED_EVENT);
                    event.errorCode = "NativeCodeError";
                    event.errorMessage = e.level;
                    break;

                case "COMING_FROM_NOTIFICATION":
                    event = new PushNotificationEvent(PushNotificationEvent.COMING_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_STARTING_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_STARTING_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_BROUGHT_TO_FOREGROUND_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_BROUGHT_TO_FOREGROUND_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_STARTED_IN_BACKGROUND_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_STARTED_IN_BACKGROUND_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "NOTIFICATION_RECEIVED_WHEN_IN_FOREGROUND":

                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_RECEIVED_WHEN_IN_FOREGROUND_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "NOTIFICATION_SETTINGS_ENABLED":
                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_SETTINGS_ENABLED);
                    break;

                case "NOTIFICATION_SETTINGS_DISABLED":
                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_SETTINGS_DISABLED);
                    break;

				case "GET_NOTIFICATIONS_ENABLED_RESULT":
					event = new PushNotificationEvent(PushNotificationEvent.GET_NOTIFICATIONS_ENABLED_RESULT, e.level == "true");
					break;

				case "OPEN_APP_NOTIFICATION_SETTINGS":
					event = new PushNotificationEvent(PushNotificationEvent.OPEN_APP_NOTIFICATION_SETTINGS);
					break;
				case "LOG_ISSUE":
					event = new PushNotificationEvent(PushNotificationEvent.LOG_ISSUE, data);
					break;
                case "LOGGING":
                    trace(e, e.level);
                    break;

            }

            if (event != null)
                this.dispatchEvent(event);
        }

	}
}

/**
 * Copyright 2017 FreshPlanet
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.freshplanet.ane.AirPushNotification {

	import flash.events.EventDispatcher;
	import flash.events.StatusEvent;
	import flash.external.ExtensionContext;
	import flash.system.Capabilities;

    /**
     *
     */
    public class PushNotification extends EventDispatcher {

        // --------------------------------------------------------------------------------------//
        //																						 //
        // 									   PUBLIC API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

		public static const RECURRENCE_NONE:int = 0;
		public static const RECURRENCE_DAILY:int = 1;
		public static const RECURRENCE_WEEK:int = 2;
		public static const RECURRENCE_MONTH:int = 3;
		public static const RECURRENCE_YEAR:int = 4;

		public static const DEFAULT_LOCAL_NOTIFICATION_ID:int = 0;

        /**
         * If true, logs will be displayed at the ActionScript level.
         */
        public static var logEnabled:Boolean = false;

        /**
         *
         */
        public static function get isSupported():Boolean {
            return _isIOS() || _isAndroid();
        }

        /**
         *
         */
        public static function get instance():PushNotification {
            return _instance ? _instance : new PushNotification();
        }

        private function callContext(...args):*
        {
            var context: ExtensionContext = getContext();
            if(!context) {
                _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.")
                return null;
            }
            try {
                return context.call.apply(context, args);
            } catch (e: Error) {
                _log("ERROR", "Error calling extension context: " + e.message + " : " + e.getStackTrace());
            }
            return null;
        }

		/**
		 *  return true if notifs are enabled for this app in device settings
		 *  If iOS < 8 or android < 4.1 this isn't available, so will always return true.
		 */
		public function getNotificationsEnabled():void {

			if (!isSupported)
				return;

			callContext("getNotificationsEnabled");
		}

		/**
		 * Check if notificationChannel is enabled in Android notification settings
		 * @param channelId
		 * @return
		 */
		public function isNotificationChannelEnabled(channelId:String):Boolean {

			if (!isSupported)
				return false;

			if(_isIOS())
				return true;

			return callContext("checkNotificationChannelEnabled", channelId);
		}

		/**
		 * return true if OS permits sending user to settings (iOS 8, Android
		 */
		public function get canSendUserToSettings():Boolean {

			if (!isSupported)
				return false;

			return callContext("getCanSendUserToSettings");
		}

        /**
         *
         */
		public function openDeviceNotificationSettings(channelId:String = null):void {

			if(!channelId)
				channelId = "";

			if (isSupported)
                callContext("openDeviceNotificationSettings", channelId);
		}

        /**
		 * Needs Project id for Android Notifications.
		 * The project id is the one the developer used to register to gcm.
		 * @param projectId: project id to use
		 * @param iOSNotificationCategories: notification categories used on iOS (PushNotificationCategoryiOS)
		 */
		public function registerForPushNotification(projectId:String = null, iOSNotificationCategories:Array = null):void {

			if(!isSupported)
				return;

			if (_isAndroid())
                callContext("registerPush", projectId);
			else if(_isIOS())
				callContext("registerPush", iOSNotificationCategories != null ? JSON.stringify(iOSNotificationCategories) : null);
		}

        /**
         *
         * @param value
         */
		public function setBadgeNumberValue(value:int):void {

			if (isSupported)
                callContext("setBadgeNb", value);
		}

		/**
		 * Sends a local notification to the device.
		 * @param message   the local notification text displayed
		 * @param timestamp when the local notification should appear (in sec)
		 * @param title     (Android Only) Title of the local notification
		 * @param recurrenceType
         * @param notificationId
         * @param deepLinkPath
         * @param iconPath
         * @param groupId  used to group notifications together
         * @param categoryId  used to display custom summaries on iOS
         * @param makeSquare  used to display square icons on Android, will default to round
		 */
		public function sendLocalNotification(message:String,
                                              timestamp:int,
                                              title:String,
                                              recurrenceType:int = RECURRENCE_NONE,
											  notificationId:int = DEFAULT_LOCAL_NOTIFICATION_ID,
                                              deepLinkPath:String = null,
                                              iconPath:String = null,
                                              groupId:String = null,
											  categoryId:String = null,
											  makeSquare:Boolean = false
		):void {

			if (!isSupported)
				return;

			if(!iconPath)
				iconPath = "";

			if(!deepLinkPath)
				deepLinkPath = "";

			if(!groupId)
				groupId = "";

			if(!categoryId)
				categoryId = "";

			callContext("sendLocalNotification", message, timestamp, title, recurrenceType, notificationId, deepLinkPath, iconPath, groupId, categoryId, makeSquare);

		}

		/**
      	* Not implemented on Android for now.
      	* @param notificationId
	  	*/
	    public function cancelLocalNotification(notificationId:int = DEFAULT_LOCAL_NOTIFICATION_ID):void {

	       	if (isSupported) {

	         	if (notificationId == DEFAULT_LOCAL_NOTIFICATION_ID)
                    callContext("cancelLocalNotification");
	         	else
                    callContext("cancelLocalNotification", notificationId);
	       	}
	    }

        /**
         *
         */
		public function cancelAllLocalNotifications():void {

			if (isSupported)
                callContext("cancelAllLocalNotifications");
		}

        /**
         *
         * @param value
         */
		public function setIsAppInForeground(value:Boolean, appGroupId:String):void {

			if (isSupported)
                callContext("setIsAppInForeground", value, appGroupId);
		}

        /**
         *
         * @param listener
         */
		public function addListenerForStarterNotifications(listener:Function):void {

			if (isSupported) {

				this.addEventListener(PushNotificationEvent.APP_STARTING_FROM_NOTIFICATION_EVENT, listener);
                callContext("fetchStarterNotification");
			}
		}

		public function checkAppNotificationSettingsRequest():void {

			if (_isIOS()) {
				callContext("checkAppNotificationSettingsRequest");
			}
		}

        public function storeTrackingNotifUrl(url:String, appGroupId:String):void {

            if (isSupported)
                callContext("storeNotifTrackingInfo", url, appGroupId);
        }

		/**
		 * Create Android notification channel
		 * @param channelId
		 * @param channelName
		 * @param importance
		 * @param enableLights
		 * @param enableVibration
		 */
		public function createAndroidNotificationChannel(channelId:String, channelName:String, importance:int, enableLights:Boolean, enableVibration:Boolean):void {

			if (_isAndroid())
				callContext("createNotificationChannel", channelId, channelName, importance, enableLights, enableVibration);
		}

		// --------------------------------------------------------------------------------------//
        //																						 //
        // 									 	PRIVATE API										 //
        // 																						 //
        // --------------------------------------------------------------------------------------//

        private static const EXTENSION_ID:String = "com.freshplanet.ane.AirPushNotification";
        private static var _instance:PushNotification = null;

        /**
         * "private" singleton constructor
         */
        public function PushNotification() {

            super();

            if (_instance)
                throw Error("This is a singleton, use getInstance(), do not call the constructor directly.");

            _instance = this;
        }

        private var __context:ExtensionContext;
        private function getContext():ExtensionContext
        {
            if (!__context) {
                __context = ExtensionContext.createExtensionContext(EXTENSION_ID, null);
                if (!__context) {
                    _log("ERROR", "Extension context is null. Please check if extension.xml is setup correctly.");
                } else {
                    __context.addEventListener(StatusEvent.STATUS, _onStatus);
                }
            }
            return __context;
        }

        /**
         *
         * @param strings
         */
        private function _log(...strings):void {

            if (logEnabled) {

                strings.unshift(EXTENSION_ID);
                trace.apply(null, strings);
            }
        }

        /**
         *
         * @return  true if iOS
         */
        private static function _isIOS():Boolean {
			return Capabilities.manufacturer.indexOf("iOS") > -1 && Capabilities.os.indexOf("x86_64") < 0 && Capabilities.os.indexOf("i386") < 0;
        }

        /**
         *
         * @return  true if Android
         */
        private static function _isAndroid():Boolean {
            return Capabilities.manufacturer.indexOf("Android") > -1;
        }

        /**
         *
         * @param e
         */
        private function _onStatus(e:StatusEvent):void {

            var event:PushNotificationEvent = null;
            var data:String = e.level;

            switch (e.code) {

                case "TOKEN_SUCCESS":
                    event = new PushNotificationEvent(PushNotificationEvent.PERMISSION_GIVEN_WITH_TOKEN_EVENT);
                    event.token = e.level;
                    break;

                case "TOKEN_FAIL":
                    event = new PushNotificationEvent(PushNotificationEvent.PERMISSION_REFUSED_EVENT);
                    event.errorCode = "NativeCodeError";
                    event.errorMessage = e.level;
                    break;

                case "COMING_FROM_NOTIFICATION":
                    event = new PushNotificationEvent(PushNotificationEvent.COMING_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_STARTING_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_STARTING_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_BROUGHT_TO_FOREGROUND_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_BROUGHT_TO_FOREGROUND_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "APP_STARTED_IN_BACKGROUND_FROM_NOTIFICATION":

                    event = new PushNotificationEvent(PushNotificationEvent.APP_STARTED_IN_BACKGROUND_FROM_NOTIFICATION_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "NOTIFICATION_RECEIVED_WHEN_IN_FOREGROUND":

                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_RECEIVED_WHEN_IN_FOREGROUND_EVENT);

                    if (data != null) {

                        try {
                            event.parameters = JSON.parse(data);
                        }
                        catch (error:Error) {
                            trace("[PushNotification Error]", "cannot parse the params string", data);
                        }
                    }
                    break;

                case "NOTIFICATION_SETTINGS_ENABLED":
                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_SETTINGS_ENABLED);
                    break;

                case "NOTIFICATION_SETTINGS_DISABLED":
                    event = new PushNotificationEvent(PushNotificationEvent.NOTIFICATION_SETTINGS_DISABLED);
                    break;

				case "GET_NOTIFICATIONS_ENABLED_RESULT":
					event = new PushNotificationEvent(PushNotificationEvent.GET_NOTIFICATIONS_ENABLED_RESULT, e.level == "true");
					break;

				case "OPEN_APP_NOTIFICATION_SETTINGS":
					event = new PushNotificationEvent(PushNotificationEvent.OPEN_APP_NOTIFICATION_SETTINGS);
					break;
				case "LOG_ISSUE":
					event = new PushNotificationEvent(PushNotificationEvent.LOG_ISSUE);
					event.errorMessage = data;
					break;
                case "LOGGING":
                    trace(e, e.level);
                    break;

            }

            if (event != null)
                this.dispatchEvent(event);
        }

	}
}

store error in errorMessage

store error in errorMessage


////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.beads
{
	import flash.display.Shape;

	import org.apache.flex.core.IBeadView;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.UIBase;
	import org.apache.flex.events.Event;
	import org.apache.flex.html.Button;
	import org.apache.flex.html.Label;
	import org.apache.flex.html.TitleBar;

	public class TitleBarView extends ContainerView implements IBeadView
	{
		public function TitleBarView()
		{
			super();
		}

		/**
		 * @private
		 */
		private var _titleLabel:Label;
		public function get titleLabel():Label
		{
			return _titleLabel;
		}

		/**
		 * @private
		 */
		private var _closeButton:Button;
		public function get closeButton():Button
		{
			return closeButton;
		}

		private var _strand:IStrand;

		/**
		 *  @copy org.apache.flex.core.IBead#strand
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		override public function set strand(value:IStrand):void
		{
			super.strand = value;
			_strand = value;

			// add the label for the title and the button for the close
			_titleLabel = createTitle();
			_titleLabel.className = UIBase(_strand).className;
			_titleLabel.id = "title";
			UIBase(_strand).addElement(_titleLabel);

			_closeButton = createCloseButton();
			_closeButton.className = UIBase(_strand).className;
			_closeButton.id = "closeButton";
			UIBase(_strand).addElement(_closeButton);

			TitleBar(_strand).childrenAdded();

			UIBase(_strand).model.addEventListener('titleChange',handlePropertyChange);
			UIBase(_strand).model.addEventListener('htmlTitleChange',handlePropertyChange);
			UIBase(_strand).model.addEventListener('showCloseButtonChange',handlePropertyChange);

			// dispatch this event to force any beads to update
			UIBase(_strand).dispatchEvent(new Event("widthChanged"));
		}

		/**
		 * @private
		 */
		private function handlePropertyChange(event:Event):void
		{
			if( event.type == "showCloseButtonChange" ) {
				if( closeButton ) closeButton.visible = TitleBar(_strand).showCloseButton;
			}
			else if( event.type == "titleChange" ) {
				if( titleLabel ) {
					titleLabel.text = TitleBar(_strand).title;
				}
			}
			else if( event.type == "htmlTitleChange" ) {
				if( titleLabel ) {
					titleLabel.html = TitleBar(_strand).htmlTitle;
				}
			}

			UIBase(_strand).dispatchEvent(new Event("widthChanged"));
		}

		/**
		 * @private
		 */
		protected function createTitle() : Label
		{
			var label:Label = new Label();
			label.text = TitleBar(_strand).title;
			return label;
		}

		/**
		 * @private
		 */
		protected function createCloseButton() : Button
		{
			var upState:Shape = new Shape();
			upState.graphics.clear();
			upState.graphics.beginFill(0xCCCCCC);
			upState.graphics.drawRect(0,0,11,11);
			upState.graphics.endFill();

			var overState:Shape = new Shape();
			overState.graphics.clear();
			overState.graphics.beginFill(0x999999);
			overState.graphics.drawRect(0,0,11,11);
			overState.graphics.endFill();

			var downState:Shape = new Shape();
			downState.graphics.clear();
			downState.graphics.beginFill(0x666666);
			downState.graphics.drawRect(0, 0, 11, 11);
			downState.graphics.endFill();

			var hitArea:Shape = new Shape();
			hitArea.graphics.clear();
			hitArea.graphics.beginFill(0x000000);
			hitArea.graphics.drawRect(0, 0, 11, 11);
			hitArea.graphics.endFill();

			var button:Button = new Button();
			button.upState = upState;
			button.overState = overState;
			button.downState = downState;
			button.hitTestState = hitArea;
			button.visible = TitleBar(_strand).showCloseButton;

			button.addEventListener('click',closeButtonHandler);

			return button;
		}

		/**
		 * @private
		 */
		private function closeButtonHandler(event:org.apache.flex.events.Event) : void
		{
			var newEvent:Event = new Event('close',true);
			UIBase(_strand).dispatchEvent(newEvent);
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.beads
{
	import flash.display.Shape;

	import org.apache.flex.core.IBeadView;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.UIBase;
	import org.apache.flex.events.Event;
	import org.apache.flex.html.Button;
	import org.apache.flex.html.Label;
	import org.apache.flex.html.TitleBar;

	public class TitleBarView extends ContainerView implements IBeadView
	{
		public function TitleBarView()
		{
			super();
		}

		/**
		 * @private
		 */
		private var _titleLabel:Label;
		public function get titleLabel():Label
		{
			return _titleLabel;
		}

		/**
		 * @private
		 */
		private var _closeButton:Button;
		public function get closeButton():Button
		{
			return closeButton;
		}

		/**
		 *  @copy org.apache.flex.core.IBead#strand
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		override public function set strand(value:IStrand):void
		{
			super.strand = value;

			// add the label for the title and the button for the close
			_titleLabel = createTitle();
			_titleLabel.className = UIBase(_strand).className;
			_titleLabel.id = "title";
			UIBase(_strand).addElement(_titleLabel);

			_closeButton = createCloseButton();
			_closeButton.className = UIBase(_strand).className;
			_closeButton.id = "closeButton";
			UIBase(_strand).addElement(_closeButton);

			TitleBar(_strand).childrenAdded();

			UIBase(_strand).model.addEventListener('titleChange',handlePropertyChange);
			UIBase(_strand).model.addEventListener('htmlTitleChange',handlePropertyChange);
			UIBase(_strand).model.addEventListener('showCloseButtonChange',handlePropertyChange);

			// dispatch this event to force any beads to update
			UIBase(_strand).dispatchEvent(new Event("widthChanged"));
		}

		/**
		 * @private
		 */
		private function handlePropertyChange(event:Event):void
		{
			if( event.type == "showCloseButtonChange" ) {
				if( closeButton ) closeButton.visible = TitleBar(_strand).showCloseButton;
			}
			else if( event.type == "titleChange" ) {
				if( titleLabel ) {
					titleLabel.text = TitleBar(_strand).title;
				}
			}
			else if( event.type == "htmlTitleChange" ) {
				if( titleLabel ) {
					titleLabel.html = TitleBar(_strand).htmlTitle;
				}
			}

			UIBase(_strand).dispatchEvent(new Event("widthChanged"));
		}

		/**
		 * @private
		 */
		protected function createTitle() : Label
		{
			var label:Label = new Label();
			label.text = TitleBar(_strand).title;
			return label;
		}

		/**
		 * @private
		 */
		protected function createCloseButton() : Button
		{
			var upState:Shape = new Shape();
			upState.graphics.clear();
			upState.graphics.beginFill(0xCCCCCC);
			upState.graphics.drawRect(0,0,11,11);
			upState.graphics.endFill();

			var overState:Shape = new Shape();
			overState.graphics.clear();
			overState.graphics.beginFill(0x999999);
			overState.graphics.drawRect(0,0,11,11);
			overState.graphics.endFill();

			var downState:Shape = new Shape();
			downState.graphics.clear();
			downState.graphics.beginFill(0x666666);
			downState.graphics.drawRect(0, 0, 11, 11);
			downState.graphics.endFill();

			var hitArea:Shape = new Shape();
			hitArea.graphics.clear();
			hitArea.graphics.beginFill(0x000000);
			hitArea.graphics.drawRect(0, 0, 11, 11);
			hitArea.graphics.endFill();

			var button:Button = new Button();
			button.upState = upState;
			button.overState = overState;
			button.downState = downState;
			button.hitTestState = hitArea;
			button.visible = TitleBar(_strand).showCloseButton;

			button.addEventListener('click',closeButtonHandler);

			return button;
		}

		/**
		 * @private
		 */
		private function closeButtonHandler(event:org.apache.flex.events.Event) : void
		{
			var newEvent:Event = new Event('close',true);
			UIBase(_strand).dispatchEvent(newEvent);
		}
	}
}

fix asdoc issue

fix asdoc issue