//
// Flump - Copyright 2012 Three Rings Design

package flump.xfl {

import flash.utils.Dictionary;

public class XflMovie extends XflTopLevelComponent
{
    use namespace xflns;

    public var md5 :String;
    public var libraryItem :String;
    public var symbol :String;
    public var layers :Array;

    public function XflMovie (baseLocation :String, xml :XML, md5 :String) {
        const converter :XmlConverter = new XmlConverter(xml);
        libraryItem = converter.getStringAttr("name");
        super(baseLocation + ":" + libraryItem);
        this.md5 = md5;
        symbol = converter.getStringAttr("linkageClassName", null);

        const layerEls :XMLList = xml.timeline.DOMTimeline[0].layers.DOMLayer;
        if (new XmlConverter(layerEls[0]).getStringAttr("name") == "flipbook") {
            layers = [new XflLayer(location, layerEls[0], _errors, true)];
            if (symbol == null) {
                addError(ParseError.CRIT, "Flipbook movie '" + libraryItem + "' not exported");
            }
        } else {
            layers = new Array();
            for each (var layerEl :XML in layerEls) {
                layers.push(new XflLayer(location, layerEl, _errors, false));
            }
        }
    }

    public function checkSymbols (lookup :Dictionary) :void {
        if (flipbook && !lookup.hasOwnProperty(symbol)) {
            addError(ParseError.CRIT, "Flipbook movie '" + symbol + "' not exported");
        } else for each (var layer :XflLayer in layers) layer.checkSymbols(lookup);
    }

    public function get flipbook () :Boolean { return layers[0].flipbook; }
}
}

//
// Flump - Copyright 2012 Three Rings Design

package flump.xfl {

import flash.utils.Dictionary;

public class XflMovie extends XflTopLevelComponent
{
    use namespace xflns;

    public var md5 :String;
    public var libraryItem :String;
    public var symbol :String;
    public var layers :Array;

    public function XflMovie (baseLocation :String, xml :XML, md5 :String) {
        const converter :XmlConverter = new XmlConverter(xml);
        libraryItem = converter.getStringAttr("name");
        super(baseLocation + ":" + libraryItem);
        this.md5 = md5;
        symbol = converter.getStringAttr("linkageClassName", null);

        const layerEls :XMLList = xml.timeline.DOMTimeline[0].layers.DOMLayer;
        if (new XmlConverter(layerEls[0]).getStringAttr("name") == "flipbook") {
            layers = [new XflLayer(location, layerEls[0], _errors, true)];
            if (symbol == null) {
                addError(ParseError.CRIT, "Flipbook movie '" + libraryItem + "' not exported");
            }
        } else {
            layers = new Array();
            for each (var layerEl :XML in layerEls) {
                layers.unshift(new XflLayer(location, layerEl, _errors, false));
            }
        }
    }

    public function checkSymbols (lookup :Dictionary) :void {
        if (flipbook && !lookup.hasOwnProperty(symbol)) {
            addError(ParseError.CRIT, "Flipbook movie '" + symbol + "' not exported");
        } else for each (var layer :XflLayer in layers) layer.checkSymbols(lookup);
    }

    public function get flipbook () :Boolean { return layers[0].flipbook; }
}
}

Order layers for correct display.

Order layers for correct display.


package org.mangui.hls
{
    import flash.external.ExternalInterface;
    import org.hola.ZExternalInterface;
    import org.hola.JSAPI;
    import org.hola.HSettings;
    import org.mangui.hls.event.HLSEvent;

    public class HLSJS
    {
        private static var _inited:Boolean = false;
        private static var _duration:Number;
        private static var _bandwidth:Number = -1;
        private static var _url:String;
        private static var _hls:HLS;

        public static function init():void{
            if (_inited || !ZExternalInterface.avail())
                return;
            _inited = true;
            JSAPI.init();
            ExternalInterface.addCallback("hola_version", hola_version);
            ExternalInterface.addCallback("hola_hls_get_video_url",
                hola_hls_get_video_url);
            ExternalInterface.addCallback("hola_hls_get_position",
                hola_hls_get_position);
            ExternalInterface.addCallback("hola_hls_get_duration",
                hola_hls_get_duration);
            ExternalInterface.addCallback("hola_hls_get_buffer_sec",
                hola_hls_get_buffer_sec);
            ExternalInterface.addCallback("hola_hls_get_state",
                hola_hls_get_state);
            ExternalInterface.addCallback("hola_hls_get_levels",
                hola_hls_get_levels);
            ExternalInterface.addCallback("hola_hls_get_level",
                hola_hls_get_level);
            ExternalInterface.addCallback("hola_setBandwidth",
                hola_setBandwidth);
        }

        public static function HLSnew(hls:HLS):void{
            _hls = hls;
            // notify js events
            hls.addEventListener(HLSEvent.MANIFEST_LOADING, on_event);
            hls.addEventListener(HLSEvent.MANIFEST_PARSED, on_event);
            hls.addEventListener(HLSEvent.MANIFEST_LOADED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADING, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADING_ABORTED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_SWITCH, on_event);
            hls.addEventListener(HLSEvent.LEVEL_ENDLIST, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOADING, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOADED, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOAD_EMERGENCY_ABORTED,
                on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_PLAYING, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_SKIPPED, on_event);
            hls.addEventListener(HLSEvent.AUDIO_TRACKS_LIST_CHANGE, on_event);
            hls.addEventListener(HLSEvent.AUDIO_TRACK_SWITCH, on_event);
            hls.addEventListener(HLSEvent.AUDIO_LEVEL_LOADING, on_event);
            hls.addEventListener(HLSEvent.AUDIO_LEVEL_LOADED, on_event);
            hls.addEventListener(HLSEvent.TAGS_LOADED, on_event);
            hls.addEventListener(HLSEvent.LAST_VOD_FRAGMENT_LOADED, on_event);
            hls.addEventListener(HLSEvent.WARNING, on_event);
            hls.addEventListener(HLSEvent.ERROR, on_event);
            hls.addEventListener(HLSEvent.MEDIA_TIME, on_event);
            hls.addEventListener(HLSEvent.PLAYBACK_STATE, on_event);
            hls.addEventListener(HLSEvent.SEEK_STATE, on_event);
            hls.addEventListener(HLSEvent.STREAM_TYPE_DID_CHANGE, on_event);
            hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, on_event);
            hls.addEventListener(HLSEvent.PLAYLIST_DURATION_UPDATED,
                on_event);
            hls.addEventListener(HLSEvent.ID3_UPDATED, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP_LEVEL_CAPPING, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP_SMOOTH_LEVEL_SWITCH,
                on_event);
            hls.addEventListener(HLSEvent.LIVE_LOADING_STALLED, on_event);
            // track duration events
            hls.addEventListener(HLSEvent.MANIFEST_LOADED, on_manifest_loaded);
            hls.addEventListener(HLSEvent.PLAYLIST_DURATION_UPDATED,
                on_playlist_duration_updated);
            // track playlist url
            hls.addEventListener(HLSEvent.MANIFEST_LOADING, on_manifest_loading);
            JSAPI.postMessage2({id: 'flashls.hlsNew', hls_id: hls.id});
        }

        public static function HLSdispose(hls:HLS):void{
            JSAPI.postMessage2({id: 'flashls.hlsDispose', hls_id: hls.id});
            _hls = null;
        }

        public static function get bandwidth():Number{
            return HSettings.hls_mode ? _bandwidth : -1;
        }

        private static function on_manifest_loaded(e:HLSEvent):void{
            _duration = e.levels[_hls.startLevel].duration;
        }

        private static function on_playlist_duration_updated(e:HLSEvent):void{
            _duration = e.duration;
        }

        private static function on_manifest_loading(e:HLSEvent):void{
            _url = e.url;
        }

        private static function on_event(e:HLSEvent):void{
            JSAPI.postMessage2({id: 'flashls.'+e.type, hls_id: _hls.id,
                url: e.url, level: e.level, duration: e.duration, levels: e.levels,
                error: e.error, loadMetrics: e.loadMetrics,
                playMetrics: e.playMetrics, mediatime: e.mediatime, state: e.state,
                audioTrack: e.audioTrack, streamType: e.streamType});
        }

        private static function hola_version():Object{
            return {
                flashls_version: '0.4.2.1',
                patch_version: '2.0.1'
            };
        }

        private static function hola_hls_get_video_url():String{
            return _url;
        }

        private static function hola_hls_get_position():Number{
            return _hls.position;
        }

        private static function hola_hls_get_duration():Number{
            return _duration;
        }

        private static function hola_hls_get_buffer_sec():Number{
            return _hls.stream.bufferLength;
        }

        private static function hola_hls_get_state():String{
            return _hls.playbackState;
        }

        private static function hola_hls_get_levels():Object{
            return _hls.levels;
        }

        private static function hola_hls_get_level():Number{
            return _hls.loadLevel;
        }

        private static function hola_setBandwidth(bandwidth:Number):void{
            _bandwidth = bandwidth;
        }
    }
}

package org.mangui.hls
{
    import flash.external.ExternalInterface;
    import org.hola.ZExternalInterface;
    import org.hola.JSAPI;
    import org.hola.HSettings;
    import org.mangui.hls.event.HLSEvent;

    public class HLSJS
    {
        private static var _inited:Boolean = false;
        private static var _duration:Number;
        private static var _bandwidth:Number = -1;
        private static var _url:String;
        private static var _hls:HLS;

        public static function init():void{
            if (_inited || !ZExternalInterface.avail())
                return;
            _inited = true;
            JSAPI.init();
            ExternalInterface.addCallback("hola_version", hola_version);
            ExternalInterface.addCallback("hola_hls_get_video_url",
                hola_hls_get_video_url);
            ExternalInterface.addCallback("hola_hls_get_position",
                hola_hls_get_position);
            ExternalInterface.addCallback("hola_hls_get_duration",
                hola_hls_get_duration);
            ExternalInterface.addCallback("hola_hls_get_buffer_sec",
                hola_hls_get_buffer_sec);
            ExternalInterface.addCallback("hola_hls_get_state",
                hola_hls_get_state);
            ExternalInterface.addCallback("hola_hls_get_levels",
                hola_hls_get_levels);
            ExternalInterface.addCallback("hola_hls_get_level",
                hola_hls_get_level);
            ExternalInterface.addCallback("hola_setBandwidth",
                hola_setBandwidth);
        }

        public static function HLSnew(hls:HLS):void{
            _hls = hls;
            // notify js events
            hls.addEventListener(HLSEvent.MANIFEST_LOADING, on_event);
            hls.addEventListener(HLSEvent.MANIFEST_PARSED, on_event);
            hls.addEventListener(HLSEvent.MANIFEST_LOADED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADING, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADING_ABORTED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_LOADED, on_event);
            hls.addEventListener(HLSEvent.LEVEL_SWITCH, on_event);
            hls.addEventListener(HLSEvent.LEVEL_ENDLIST, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOADING, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOADED, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_LOAD_EMERGENCY_ABORTED,
                on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_PLAYING, on_event);
            hls.addEventListener(HLSEvent.FRAGMENT_SKIPPED, on_event);
            hls.addEventListener(HLSEvent.AUDIO_TRACKS_LIST_CHANGE, on_event);
            hls.addEventListener(HLSEvent.AUDIO_TRACK_SWITCH, on_event);
            hls.addEventListener(HLSEvent.AUDIO_LEVEL_LOADING, on_event);
            hls.addEventListener(HLSEvent.AUDIO_LEVEL_LOADED, on_event);
            hls.addEventListener(HLSEvent.TAGS_LOADED, on_event);
            hls.addEventListener(HLSEvent.LAST_VOD_FRAGMENT_LOADED, on_event);
            hls.addEventListener(HLSEvent.WARNING, on_event);
            hls.addEventListener(HLSEvent.ERROR, on_event);
            hls.addEventListener(HLSEvent.MEDIA_TIME, on_event);
            hls.addEventListener(HLSEvent.PLAYBACK_STATE, on_event);
            hls.addEventListener(HLSEvent.SEEK_STATE, on_event);
            hls.addEventListener(HLSEvent.STREAM_TYPE_DID_CHANGE, on_event);
            hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, on_event);
            hls.addEventListener(HLSEvent.PLAYLIST_DURATION_UPDATED,
                on_event);
            hls.addEventListener(HLSEvent.ID3_UPDATED, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP_LEVEL_CAPPING, on_event);
            hls.addEventListener(HLSEvent.FPS_DROP_SMOOTH_LEVEL_SWITCH,
                on_event);
            hls.addEventListener(HLSEvent.LIVE_LOADING_STALLED, on_event);
            // track duration events
            hls.addEventListener(HLSEvent.MANIFEST_LOADED, on_manifest_loaded);
            hls.addEventListener(HLSEvent.PLAYLIST_DURATION_UPDATED,
                on_playlist_duration_updated);
            // track playlist url
            hls.addEventListener(HLSEvent.MANIFEST_LOADING, on_manifest_loading);
            JSAPI.postMessage2({id: 'flashls.hlsNew', hls_id: hls.id});
        }

        public static function HLSdispose(hls:HLS):void{
            JSAPI.postMessage2({id: 'flashls.hlsDispose', hls_id: hls.id});
            _duration = 0;
            _bandwidth = -1;
            _url = null;
            _hls = null;
        }

        public static function get bandwidth():Number{
            return HSettings.hls_mode ? _bandwidth : -1;
        }

        private static function on_manifest_loaded(e:HLSEvent):void{
            _duration = e.levels[_hls.startLevel].duration;
        }

        private static function on_playlist_duration_updated(e:HLSEvent):void{
            _duration = e.duration;
        }

        private static function on_manifest_loading(e:HLSEvent):void{
            _url = e.url;
        }

        private static function on_event(e:HLSEvent):void{
            JSAPI.postMessage2({id: 'flashls.'+e.type, hls_id: _hls.id,
                url: e.url, level: e.level, duration: e.duration, levels: e.levels,
                error: e.error, loadMetrics: e.loadMetrics,
                playMetrics: e.playMetrics, mediatime: e.mediatime, state: e.state,
                audioTrack: e.audioTrack, streamType: e.streamType});
        }

        private static function hola_version():Object{
            return {
                flashls_version: '0.4.2.1',
                patch_version: '2.0.1'
            };
        }

        private static function hola_hls_get_video_url():String{
            return _url;
        }

        private static function hola_hls_get_position():Number{
            return _hls.position;
        }

        private static function hola_hls_get_duration():Number{
            return _duration;
        }

        private static function hola_hls_get_buffer_sec():Number{
            return _hls.stream.bufferLength;
        }

        private static function hola_hls_get_state():String{
            return _hls.playbackState;
        }

        private static function hola_hls_get_levels():Object{
            return _hls.levels;
        }

        private static function hola_hls_get_level():Number{
            return _hls.loadLevel;
        }

        private static function hola_setBandwidth(bandwidth:Number):void{
            _bandwidth = bandwidth;
        }
    }
}

reset state on dispose

reset state on dispose


package aerys.minko.scene.visitor.data
{
	import aerys.minko.render.RenderTarget;
	import aerys.minko.render.Viewport;
	import aerys.minko.render.effect.IEffect;

	import flash.utils.Dictionary;

	public class ViewportData implements IWorldData
	{
		public static const RATIO 				: String = 'ratio';
		public static const WIDTH				: String = 'width';
		public static const HEIGHT				: String = 'height';
		public static const ANTIALIASING		: String = 'antialiasing';
		public static const BACKGROUND_COLOR	: String = 'backgroundColor';

		protected var _viewport					: Viewport;
		protected var _renderTarget				: RenderTarget;

		public function get ratio() : Number
		{
			return _viewport.width / _viewport.height;
		}

		public function get width() : int
		{
			return _viewport.width;
		}

		public function get height() : int
		{
			return _viewport.height;
		}

		public function get antiAliasing() : int
		{
			return _viewport.antiAliasing;
		}

		public function get backgroundColor() : uint
		{
			return _viewport.backgroundColor;
		}

		public function get defaultEffect() : IEffect
		{
			return _viewport.defaultEffect;
		}

		public function get renderTarget() : RenderTarget
		{
			var viewportWidth		: int = _viewport.width;
			var viewportHeight		: int = _viewport.height;
			var viewportAntialias	: int = _viewport.antiAliasing;
			var viewportBgColor		: int = _viewport.backgroundColor;

			if (_renderTarget == null
				|| viewportWidth		!= _renderTarget.width
				|| viewportHeight		!= _renderTarget.height
				|| viewportAntialias	!= _renderTarget.antiAliasing
				|| viewportBgColor		!= _renderTarget.backgroundColor)
			{
				_renderTarget = new RenderTarget(
					RenderTarget.BACKBUFFER, viewportWidth, viewportHeight,
					viewportBgColor, true, viewportAntialias);
			}

			return _renderTarget;
		}

		public function ViewportData(viewport : Viewport)
		{
			_viewport = viewport;
		}

		public function setDataProvider(styleStack	: StyleStack,
										localData	: LocalData,
										worldData	: Dictionary) : void
		{
		}

		public function invalidate() : void
		{
		}

		public function reset() : void
		{
		}
	}
}

package aerys.minko.scene.visitor.data
{
	import aerys.minko.render.RenderTarget;
	import aerys.minko.render.Viewport;
	import aerys.minko.render.effect.IEffect;

	import flash.display.Stage;
	import flash.utils.Dictionary;

	public class ViewportData implements IWorldData
	{
		public static const RATIO 				: String = 'ratio';
		public static const WIDTH				: String = 'width';
		public static const HEIGHT				: String = 'height';
		public static const ANTIALIASING		: String = 'antialiasing';
		public static const BACKGROUND_COLOR	: String = 'backgroundColor';

		protected var _viewport					: Viewport;
		protected var _renderTarget				: RenderTarget;

		public function get ratio() : Number
		{
			return _viewport.width / _viewport.height;
		}

		public function get width() : int
		{
			return _viewport.width;
		}

		public function get height() : int
		{
			return _viewport.height;
		}

		public function get antiAliasing() : int
		{
			return _viewport.antiAliasing;
		}

		public function get backgroundColor() : uint
		{
			return _viewport.backgroundColor;
		}

		public function get defaultEffect() : IEffect
		{
			return _viewport.defaultEffect;
		}

		public function get renderTarget() : RenderTarget
		{
			var viewportWidth		: int = _viewport.width;
			var viewportHeight		: int = _viewport.height;
			var viewportAntialias	: int = _viewport.antiAliasing;
			var viewportBgColor		: int = _viewport.backgroundColor;

			if (_renderTarget == null
				|| viewportWidth		!= _renderTarget.width
				|| viewportHeight		!= _renderTarget.height
				|| viewportAntialias	!= _renderTarget.antiAliasing
				|| viewportBgColor		!= _renderTarget.backgroundColor)
			{
				_renderTarget = new RenderTarget(
					RenderTarget.BACKBUFFER, viewportWidth, viewportHeight,
					viewportBgColor, true, viewportAntialias);
			}

			return _renderTarget;
		}

		public function get stage() : Stage
		{
			return _viewport.stage;
		}

		public function ViewportData(viewport : Viewport)
		{
			_viewport = viewport;
		}

		public function setDataProvider(styleStack	: StyleStack,
										localData	: LocalData,
										worldData	: Dictionary) : void
		{
		}

		public function invalidate() : void
		{
		}

		public function reset() : void
		{
		}
	}
}

Add a new getter into ViewportData, to be able to access the stage.


/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (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.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is [ActiveScripting implemented with Tamarin].
 *
 * The Initial Developer of the Original Code is Mozilla Corp.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Mark Hammond
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

// hackery - for now, this file is "built" via:
// % java -ea -DAS3 -Xmx200m -DAVMPLUS -classpath ../utils/asc.jar macromedia.asc.embedding.ScriptCompiler -abcfuture -builtin -import ../core/builtin.abc -import ../esc/bin/parse.es.abc -import ../esc/bin/cogen.es.abc -out axtoplevel mscom.as Domain.as ../shell/ByteArray.as && move /y ..\shell\axtoplevel.* .

package axtam
{
	// should possibly be private...
	public class System
	{
		public native static function getAvmplusVersion():String
		public native static function write(s:String):void
		public native static function trace(a:Array):void
		public native static function debugger():void
		public native static function isDebugger():Boolean
		public native static function nativeDebugBreak():void
	}
}

package
{
	// a global 'print' statement...
	public function print(...s)
	{
		axtam.System.trace(s)
	}

}

package axtam.com {
	// Its not clear if we should subclass the standard 'Error', but given
	// it has its own concept of 'Message' and 'ID', it doesn't seem a good fit.
	// Maybe a new base-class should be introduced.
	public dynamic class Error
	{
		public static const E_NOTIMPL = 0x80004001
		public static const E_INVALIDARG = 0x80070057
		public static const E_UNEXPECTED = 0x8000ffff
		public static const E_FAIL = 0x80004005
		public static const E_NOINTERFACE = 0x80000004

		public var hresult: int
		function Error(hresult) {
			this.hresult = hresult;
			print('Error constructed')
		}

		prototype.toString = function():String
		{
			var e:axtam.com.Error = this
			return e.message !== "" ? e.name + ": " + e.message : e.name;
		}
		_setPropertyIsEnumerable(prototype, "toString", false);

		public native static function getErrorMessage(index:int):String;

		public static function throwError(hresult:int, ... rest)
		{
			// todo: rich error support?
			//throw new axtam.com.Error(hresult);
		}

	}
	// constants go directly in the axtam.com package.
	public const SCRIPTINFO_IUNKNOWN = 0x00000001
	public const SCRIPTINFO_ITYPEINFO = 0x00000002

	public const SCRIPTITEM_ISVISIBLE = 0x00000002
	public const SCRIPTITEM_ISSOURCE = 0x00000004
	public const SCRIPTITEM_GLOBALMEMBERS = 0x00000008
	public const SCRIPTITEM_ISPERSISTENT = 0x00000040
	public const SCRIPTITEM_CODEONLY = 0x00000200
	public const SCRIPTITEM_NOCODE = 0x00000400

}

package axtam.com.adaptors.consumer {
	// scripting interfaces we consume in AS (ie, implemented externally)
	// Each method listed here corresponds to a native method in the engine,
	// which inturn delegates to the real COM object.
	// Note that some of these classes have no scriptable methods, but they
	// are used internally
	public class IUnknown
	{
	}

	// XXX - technically the rest of these 'derive' from IUnknown...
	public class IDispatch
	{
	}

	public class ITypeInfo
	{
	}

	public class IActiveScriptSite
	{
		// somewhat like GetItemInfo() - but gets both IDispatch and ITypelib,
		// and wraps them in a ScriptObject which can be used from script.
		public native function GetItemInfo(name:String, flags:uint):Array
		public native function GetDocVersionString(): String
	}
}

package {

    import flash.utils.*; // for our ByteArray clone - either it should die, or we rename the package in our clone!

    public function execString(str, domain)
    {
        import Parse.*;
        var top = []
        var parser = new Parse.Parser(str,top);
        var prog = parser.program();
        var ts = prog[0]
        var nd = prog[1]
        var bytes = Gen::cg(nd).getBytes();

        var b = new ByteArray();
        b.endian = "littleEndian";

        for (var i = 0, len = bytes.length; i<len; ++i) {
            b.writeByte(uint(bytes[i]));
        }
        domain.loadBytes(b);
    }

   }

package {

	class ScriptEngine {
			public var globalDomain:axtam.Domain;
			public var objectDomains; // A hashtable of named objects to their domains.
			public var state:int;
			public function ScriptEngine() {
			}
			public function InitNew() {
				//domain = Domain.currentDomain
				globalDomain = new axtam.Domain(null, null)
				objectDomains = {}
			}
			public function ParseScriptText(code:String, itemName:String, context:Object, delim:String, sourceCookie:int, lineNumber:int, flags:int) {
				print('ParseScriptText')
				print(code)
				// XXX - this is wrong - we should only do the parse and generation
				// of bytecode here.  We should execute all such blocks at
				// SetScriptState(SCRIPTSTATE_RUNNING) time.
				var domain = objectDomains[itemName]
				if (!domain)
					domain = globalDomain
				execString(code, domain)

			}
			// This function is called as a 'named item' is added to the environment.
			// Examples include IE's 'window' object.
			public function AddNamedItem(name:String, flags:uint):void
			{
				print('AddNamedItem(', name, flags)
				var site = new axtam.com.adaptors.consumer.IActiveScriptSite()
				// MS docs say we should avoid grabbing typeinfo unless we
				// really need it.  At this stage, we need it if the item is
				// "global", and later will need it if it sources events
				var gii_flags:uint = axtam.com.SCRIPTINFO_IUNKNOWN
				if (flags & axtam.com.SCRIPTITEM_GLOBALMEMBERS)
					gii_flags |= axtam.com.SCRIPTINFO_ITYPEINFO

				var items = site.GetItemInfo(name, gii_flags)
				var dispatch = items[0]
				var typeinfo = items[1]
				globalDomain.global[name] = dispatch
				// but we also need to tell the VM exactly what 'scope'
				// provides this object.
				globalDomain.addNamedScriptObject(name)
				// if its global, we enumerate items and make them public - all
				// this is done inside exposeGlobalMembers
				//if (flags & axtam.com.SCRIPTITEM_GLOBALMEMBERS && typeinfo != null) {
				//	domain.exposeGlobalMembers(dispatch, typeinfo)
				//}
				// create a new domain for the object with the IDispatch as its global.
				var obDomain =  new axtam.Domain(globalDomain, dispatch)
				objectDomains[name] = obDomain
			}

			public function GetScriptState(): uint
			{
				return state;
			}

			public function SetScriptState(new_state:uint): void
			{
				// don't allow new state transitions once we are closed.
				axtam.com.Error.throwError(axtam.com.Error.E_INVALIDARG)
			}

	}

	public var engine = new ScriptEngine()
	// and magically methods will be called on 'engine'
}

/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (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.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is [ActiveScripting implemented with Tamarin].
 *
 * The Initial Developer of the Original Code is Mozilla Corp.
 * Portions created by the Initial Developer are Copyright (C) 2007
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Mark Hammond
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

// hackery - for now, this file is "built" via:
// % java -ea -DAS3 -Xmx200m -DAVMPLUS -classpath ../utils/asc.jar macromedia.asc.embedding.ScriptCompiler -abcfuture -builtin -import ../core/builtin.abc -import ../esc/bin/parse.es.abc -import ../esc/bin/cogen.es.abc -out axtoplevel mscom.as Domain.as ../shell/ByteArray.as && move /y ..\shell\axtoplevel.* .

package axtam
{
	// should possibly be private...
	public class System
	{
		public native static function getAvmplusVersion():String
		public native static function write(s:String):void
		public native static function trace(a:Array):void
		public native static function debugger():void
		public native static function isDebugger():Boolean
		public native static function nativeDebugBreak():void
	}
}

package
{
	// a global 'print' statement...
	public function print(...s)
	{
		axtam.System.trace(s)
	}

}

package axtam.com {
	// Its not clear if we should subclass the standard 'Error', but given
	// it has its own concept of 'Message' and 'ID', it doesn't seem a good fit.
	// Maybe a new base-class should be introduced.
	public dynamic class Error
	{
		public static const E_NOTIMPL = 0x80004001
		public static const E_INVALIDARG = 0x80070057
		public static const E_UNEXPECTED = 0x8000ffff
		public static const E_FAIL = 0x80004005
		public static const E_NOINTERFACE = 0x80000004

		public var hresult: int
		function Error(hresult) {
			this.hresult = hresult;
			print('Error constructed')
		}

		prototype.toString = function():String
		{
			var e:axtam.com.Error = this
			return e.message !== "" ? e.name + ": " + e.message : e.name;
		}
		_setPropertyIsEnumerable(prototype, "toString", false);

		public native static function getErrorMessage(index:int):String;

		public static function throwError(hresult:int, ... rest)
		{
			// todo: rich error support?
			//throw new axtam.com.Error(hresult);
		}

	}
	// constants go directly in the axtam.com package.
	public const SCRIPTINFO_IUNKNOWN = 0x00000001
	public const SCRIPTINFO_ITYPEINFO = 0x00000002

	public const SCRIPTITEM_ISVISIBLE = 0x00000002
	public const SCRIPTITEM_ISSOURCE = 0x00000004
	public const SCRIPTITEM_GLOBALMEMBERS = 0x00000008
	public const SCRIPTITEM_ISPERSISTENT = 0x00000040
	public const SCRIPTITEM_CODEONLY = 0x00000200
	public const SCRIPTITEM_NOCODE = 0x00000400

}

package axtam.com.adaptors.consumer {
	// scripting interfaces we consume in AS (ie, implemented externally)
	// Each method listed here corresponds to a native method in the engine,
	// which inturn delegates to the real COM object.
	// Note that some of these classes have no scriptable methods, but they
	// are used internally
	public class IUnknown
	{
	}

	// XXX - technically the rest of these 'derive' from IUnknown...
	public class IDispatch
	{
	}

	public class ITypeInfo
	{
	}

	public class IActiveScriptSite
	{
		// somewhat like GetItemInfo() - but gets both IDispatch and ITypelib,
		// and wraps them in a ScriptObject which can be used from script.
		public native function GetItemInfo(name:String, flags:uint):Array
		public native function GetDocVersionString(): String
	}
}

package {

    import flash.utils.*; // for our ByteArray clone - either it should die, or we rename the package in our clone!

    public function execString(str, domain)
    {
        import Parse.*;
        var top = []
        var parser = new Parse.Parser(str,top);
        var prog = parser.program();
        var ts = prog[0]
        var nd = prog[1]
        var bytes = Gen::cg(nd).getBytes();

        var b = new ByteArray();
        b.endian = "littleEndian";

        for (var i = 0, len = bytes.length; i<len; ++i) {
            b.writeByte(uint(bytes[i]));
        }
        domain.loadBytes(b);
    }

   }

package {

	class ScriptEngine {
			public var globalDomain:axtam.Domain;
			public var objectDomains; // A hashtable of named objects to their domains.
			public var state:int;
			public function ScriptEngine() {
			}
			public function InitNew() {
				//domain = Domain.currentDomain
				globalDomain = new axtam.Domain(null, null)
				objectDomains = {}
			}
			public function ParseScriptText(code:String, itemName:String, context:Object, delim:String, sourceCookie:int, lineNumber:int, flags:int) {
				// XXX - this is wrong - we should only do the parse and generation
				// of bytecode here.  We should execute all such blocks at
				// SetScriptState(SCRIPTSTATE_RUNNING) time.
				var domain = objectDomains[itemName]
				if (!domain)
					domain = globalDomain
				execString(code, domain)

			}
			// This function is called as a 'named item' is added to the environment.
			// Examples include IE's 'window' object.
			public function AddNamedItem(name:String, flags:uint):void
			{
				print('AddNamedItem(', name, flags)
				var site = new axtam.com.adaptors.consumer.IActiveScriptSite()
				// MS docs say we should avoid grabbing typeinfo unless we
				// really need it.  At this stage, we need it if the item is
				// "global", and later will need it if it sources events
				var gii_flags:uint = axtam.com.SCRIPTINFO_IUNKNOWN
				if (flags & axtam.com.SCRIPTITEM_GLOBALMEMBERS)
					gii_flags |= axtam.com.SCRIPTINFO_ITYPEINFO

				var items = site.GetItemInfo(name, gii_flags)
				var dispatch = items[0]
				var typeinfo = items[1]
				globalDomain.global[name] = dispatch
				// but we also need to tell the VM exactly what 'scope'
				// provides this object.
				globalDomain.addNamedScriptObject(name)
				// if its global, we enumerate items and make them public - all
				// this is done inside exposeGlobalMembers
				//if (flags & axtam.com.SCRIPTITEM_GLOBALMEMBERS && typeinfo != null) {
				//	domain.exposeGlobalMembers(dispatch, typeinfo)
				//}
				// create a new domain for the object with the IDispatch as its global.
				var obDomain =  new axtam.Domain(globalDomain, dispatch)
				objectDomains[name] = obDomain
			}

			public function GetScriptState(): uint
			{
				return state;
			}

			public function SetScriptState(new_state:uint): void
			{
				// don't allow new state transitions once we are closed.
				axtam.com.Error.throwError(axtam.com.Error.E_INVALIDARG)
			}

	}

	public var engine = new ScriptEngine()
	// and magically methods will be called on 'engine'
}

Remove debug prints

Remove debug prints


package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.scene.SceneIterator;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.type.Signal;
	import aerys.minko.type.Sort;
	import aerys.minko.type.loader.ILoader;
	import aerys.minko.type.loader.SceneLoader;
	import aerys.minko.type.loader.parser.ParserOptions;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	import flash.net.URLRequest;
	import flash.utils.ByteArray;
	import flash.utils.Proxy;
	import flash.utils.flash_proxy;
	import flash.utils.getQualifiedClassName;

	/**
	 * Group objects can contain other scene nodes and applies a 3D
	 * transformation to its descendants.
	 *
	 * @author Jean-Marc Le Roux
	 */
	public class Group extends AbstractSceneNode
	{
		use namespace minko_scene;

		minko_scene var _children		: Vector.<ISceneNode>	= null;
		minko_scene var _numChildren	: uint					= 0;

		private var _numDescendants		: uint					= 0;

		private var _descendantAdded	: Signal				= new Signal('Group.descendantAdded');
		private var _descendantRemoved	: Signal				= new Signal('Group.descendantRemoved');

		/**
		 * The number of children of the Group.
		 */
		public function get numChildren() : uint
		{
			return _numChildren;
		}

		/**
		 * The number of descendants of the Group.
		 *
		 * @return
		 *
		 */
		public function get numDescendants() : uint
		{
			return _numDescendants;
		}

		/**
		 * The signal executed when a descendant is added to the Group.
		 * Callbacks for this signal must accept the following arguments:
		 *

		 *
newParent : Group, the Group the descendant was actually added to

		 *
descendant : ISceneNode, the descendant that was just added

		 *

		 *
		 * @return
		 *
		 */
		public function get descendantAdded() : Signal
		{
			return _descendantAdded
		}

		/**
		 * The signal executed when a descendant is removed from the Group.
		 * Callbacks for this signal must accept the following arguments:
		 *

		 *
oldParent : Group, the Group the descendant was actually removed from

		 *
descendant : ISceneNode, the descendant that was just removed

		 *

		 *
		 * @return
		 *
		 */
		public function get descendantRemoved() : Signal
		{
			return _descendantRemoved;
		}

		public function Group(...children)
		{
			super();

			initialize();
			initializeChildren(children);
		}

		private function initialize() : void
		{
			_children = new <ISceneNode>[];

			descendantAdded.add(descendantAddedHandler);
			descendantRemoved.add(descendantRemovedHandler);
		}

		protected function initializeChildren(children : Array) : void
		{
			while (children.length == 1 && children[0] is Array)
				children = children[0];

			var childrenNum : uint = children.length;

			for (var childrenIndex : uint = 0; childrenIndex < childrenNum; ++childrenIndex)
				addChild(ISceneNode(children[childrenIndex]));
		}

		override protected function addedHandler(child : ISceneNode, parent : Group) : void
		{
			super.addedHandler(child, parent);

			for (var childIndex : int = 0; childIndex < _numChildren; ++childIndex)
				_children[childIndex].added.execute(child, parent);
		}

		override protected function removedHandler(child : ISceneNode, parent : Group) : void
		{
			super.removedHandler(child, parent);

			for (var childIndex : int = 0; childIndex < _numChildren; ++childIndex)
				_children[childIndex].removed.execute(child, parent);
		}

		private function descendantAddedHandler(group : Group, child : ISceneNode) : void
		{
			if (group == this)
			{
				var childGroup : Group = child as Group;

				if (childGroup)
				{
					childGroup.descendantAdded.add(_descendantAdded.execute);
					childGroup.descendantRemoved.add(_descendantRemoved.execute);
				}
			}

			_numDescendants += (child is Group) ? (child as Group)._numDescendants + 1 : 1;
		}

		private function descendantRemovedHandler(group : Group, child : ISceneNode) : void
		{
			if (group == this)
			{
				var childGroup : Group = child as Group;

				if (childGroup)
				{
					childGroup.descendantAdded.remove(_descendantAdded.execute);
					childGroup.descendantRemoved.remove(_descendantRemoved.execute);
				}
			}

			_numDescendants -= (child is Group) ? (child as Group)._numDescendants + 1 : 1;
		}

		/**
		 * Return true if the specified scene node is a child of the Group, false otherwise.
		 *
		 * @param scene
		 * @return
		 *
		 */
		public function contains(scene : ISceneNode) : Boolean
		{
			return getChildIndex(scene) >= 0;
		}

		/**
		 * Return the index of the speficied scene node or -1 if it is not in the Group.
		 *
		 * @param child
		 * @return
		 *
		 */
		public function getChildIndex(child : ISceneNode) : int
		{
			if (child == null)
				throw new Error('The \'child\' parameter cannot be null.');

			for (var i : int = 0; i < _numChildren; i++)
				if (_children[i] === child)
					return i;

			return -1;
		}

		public function getChildByName(name : String) : ISceneNode
		{
			for (var i : int = 0; i < _numChildren; i++)
				if (_children[i].name === name)
					return _children[i];

			return null;
		}

		/**
		 * Add a child to the group.
		 *
		 * @param	scene The child to add.
		 */
		public function addChild(node : ISceneNode) : Group
		{
			return addChildAt(node, _numChildren);
		}

		/**
		 * Add a child to the group at the specified position.
		 *
		 * @param node
		 * @param position
		 * @return
		 *
		 */
		public function addChildAt(node : ISceneNode, position : uint) : Group
		{
			if (!node)
				throw new Error('Parameter \'scene\' must not be null.');

			node.parent = this;

			for (var i : int = _numChildren - 1; i > position; --i)
				_children[i] = _children[int(i - 1)];

			_children[position] = node;

			return this;
		}

		/**
		 * Remove a child from the container.
		 *
		 * @param	myChild The child to remove.
		 * @return Whether the child was actually removed or not.
		 */
		public function removeChild(child : ISceneNode) : Group
		{
			return removeChildAt(getChildIndex(child));
		}

		public function removeChildAt(position : uint) : Group
		{
			if (position >= _numChildren || position < 0)
				throw new Error('The scene node is not a child of the caller.');

			(_children[position] as ISceneNode).parent = null;

			return this;
		}

		/**
		 * Remove all the children.
		 *
		 * @return
		 *
		 */
		public function removeAllChildren() : Group
		{
			while (_numChildren)
				removeChildAt(0);

			return this;
		}

		/**
		 * Return the child at the specified position.
		 *
		 * @param position
		 * @return
		 *
		 */
		public function getChildAt(position : uint) : ISceneNode
		{
			return position < _numChildren ? _children[position] : null;
		}

		/**
		 * Returns the list of descendant scene nodes that have the specified type.
		 *
		 * @param type
		 * @param descendants
		 * @return
		 *
		 */
		public function getDescendantsByType(type 			: Class,
											 descendants 	: Vector.<ISceneNode> = null) : Vector.<ISceneNode>
		{
			descendants ||= new Vector.<ISceneNode>();

			for (var i : int = 0; i < _numChildren; ++i)
			{
				var child	: ISceneNode	= _children[i];
				var group 	: Group 		= child as Group;

				if (child is type)
					descendants.push(child);

				if (group)
					group.getDescendantsByType(type, descendants);
			}

			return descendants;
		}

		public function toString() : String
		{
			return '[' + getQualifiedClassName(this) + ' ' + name + ']';
		}

		/**
		 * Load the 3D scene corresponding to the specified URLRequest object
		 * and add it directly to the group.
		 *
		 * @param request
		 * @param options
		 * @return
		 *
		 */
		public function load(request	: URLRequest,
							 options	: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.load(request);

			return loader;
		}

		/**
		 * Load the 3D scene corresponding to the specified Class object
		 * and add it directly to the group.
		 *
		 * @param classObject
		 * @param options
		 * @return
		 *
		 */
		public function loadClass(classObject	: Class,
								  options		: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.loadClass(classObject);

			return loader;
		}

		/**
		 * Load the 3D scene corresponding to the specified ByteArray object
		 * and add it directly to the group.
		 *
		 * @param bytes
		 * @param options
		 * @return
		 *
		 */
		public function loadBytes(bytes		: ByteArray,
								  options	: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.loadBytes(bytes);

			return loader;
		}

		/**
		 * Return the set of nodes matching the specified XPath query.
		 *
		 * @param xpath
		 * @return
		 *
		 */
		public function get(xpath : String) : SceneIterator
		{
			return new SceneIterator(xpath, new <ISceneNode>[this]);
		}

		private function loaderCompleteHandler(loader	: ILoader,
											   scene	: ISceneNode) : void
		{
			addChild(scene);
		}

		/**
		 * Return all the Mesh objects hit by the specified ray.
		 *
		 * @param ray
		 * @param maxDistance
		 * @return
		 *
		 */
		public function cast(ray : Ray, maxDistance : Number = Number.POSITIVE_INFINITY) : SceneIterator
		{
			var meshes		: Vector.<ISceneNode> 	= getDescendantsByType(Mesh);
			var numMeshes	: uint					= meshes.length;
			var hit			: Array					= [];
			var depth		: Vector.<Number>		= new <Number>[];
			var numItems	: uint					= 0;

			for (var i : uint = 0; i < numMeshes; ++i)
			{
				var mesh 		: Mesh		= meshes[i] as Mesh;
				var hitDepth	: Number	= mesh.geometry.boundingBox.testRay(
					ray,
					mesh.worldToLocal,
					maxDistance
				);

				if (hitDepth >= 0.0)
				{
					hit[numItems] = mesh;
					depth[numItems] = hitDepth;
					++numItems;
				}
			}

			if (numItems > 1)
				Sort.flashSort(depth, hit, numItems);

			return new SceneIterator(null, Vector.<ISceneNode>(hit));
		}

		override public function clone(cloneControllers : Boolean = false) : ISceneNode
		{
			var cloned : Group = new Group();

			cloned.name = name;
			cloned.transform.copyFrom(transform);

			for (var childId : uint = 0; childId < _numChildren; ++childId)
				cloned.addChildAt(getChildAt(childId).clone(), childId);

			copyControllersFrom(this, cloned, cloneControllers);

			return cloned;
		}
	}
}

package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.scene.SceneIterator;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.type.Signal;
	import aerys.minko.type.Sort;
	import aerys.minko.type.loader.ILoader;
	import aerys.minko.type.loader.SceneLoader;
	import aerys.minko.type.loader.parser.ParserOptions;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	import flash.net.URLRequest;
	import flash.utils.ByteArray;
	import flash.utils.Proxy;
	import flash.utils.flash_proxy;
	import flash.utils.getQualifiedClassName;

	/**
	 * Group objects can contain other scene nodes and applies a 3D
	 * transformation to its descendants.
	 *
	 * @author Jean-Marc Le Roux
	 */
	public class Group extends AbstractSceneNode
	{
		use namespace minko_scene;

		minko_scene var _children		: Vector.<ISceneNode>	= null;
		minko_scene var _numChildren	: uint					= 0;

		private var _numDescendants		: uint					= 0;

		private var _descendantAdded	: Signal				= new Signal('Group.descendantAdded');
		private var _descendantRemoved	: Signal				= new Signal('Group.descendantRemoved');

		/**
		 * The number of children of the Group.
		 */
		public function get numChildren() : uint
		{
			return _numChildren;
		}

		/**
		 * The number of descendants of the Group.
		 *
		 * @return
		 *
		 */
		public function get numDescendants() : uint
		{
			return _numDescendants;
		}

		/**
		 * The signal executed when a descendant is added to the Group.
		 * Callbacks for this signal must accept the following arguments:
		 *

		 *
newParent : Group, the Group the descendant was actually added to

		 *
descendant : ISceneNode, the descendant that was just added

		 *

		 *
		 * @return
		 *
		 */
		public function get descendantAdded() : Signal
		{
			return _descendantAdded
		}

		/**
		 * The signal executed when a descendant is removed from the Group.
		 * Callbacks for this signal must accept the following arguments:
		 *

		 *
oldParent : Group, the Group the descendant was actually removed from

		 *
descendant : ISceneNode, the descendant that was just removed

		 *

		 *
		 * @return
		 *
		 */
		public function get descendantRemoved() : Signal
		{
			return _descendantRemoved;
		}

		public function Group(...children)
		{
			super();

			initialize();
			initializeChildren(children);
		}

		private function initialize() : void
		{
			_children = new <ISceneNode>[];

			descendantAdded.add(descendantAddedHandler);
			descendantRemoved.add(descendantRemovedHandler);
		}

		protected function initializeChildren(children : Array) : void
		{
			while (children.length == 1 && children[0] is Array)
				children = children[0];

			var childrenNum : uint = children.length;

			for (var childrenIndex : uint = 0; childrenIndex < childrenNum; ++childrenIndex)
				addChild(ISceneNode(children[childrenIndex]));
		}

		override protected function addedHandler(child : ISceneNode, parent : Group) : void
		{
			super.addedHandler(child, parent);

			for (var childIndex : int = 0; childIndex < _numChildren; ++childIndex)
				_children[childIndex].added.execute(child, parent);
		}

		override protected function removedHandler(child : ISceneNode, parent : Group) : void
		{
			super.removedHandler(child, parent);

			for (var childIndex : int = 0; childIndex < _numChildren; ++childIndex)
				_children[childIndex].removed.execute(child, parent);
		}

		private function descendantAddedHandler(group : Group, child : ISceneNode) : void
		{
			if (group == this)
			{
				var childGroup : Group = child as Group;

				if (childGroup)
				{
					childGroup.descendantAdded.add(_descendantAdded.execute);
					childGroup.descendantRemoved.add(_descendantRemoved.execute);
				}
			}

			_numDescendants += (child is Group) ? (child as Group)._numDescendants + 1 : 1;
		}

		private function descendantRemovedHandler(group : Group, child : ISceneNode) : void
		{
			if (group == this)
			{
				var childGroup : Group = child as Group;

				if (childGroup)
				{
					childGroup.descendantAdded.remove(_descendantAdded.execute);
					childGroup.descendantRemoved.remove(_descendantRemoved.execute);
				}
			}

			_numDescendants -= (child is Group) ? (child as Group)._numDescendants + 1 : 1;
		}

		/**
		 * Return true if the specified scene node is a child of the Group, false otherwise.
		 *
		 * @param scene
		 * @return
		 *
		 */
		public function contains(scene : ISceneNode) : Boolean
		{
			return getChildIndex(scene) >= 0;
		}

		/**
		 * Return the index of the speficied scene node or -1 if it is not in the Group.
		 *
		 * @param child
		 * @return
		 *
		 */
		public function getChildIndex(child : ISceneNode) : int
		{
			if (child == null)
				throw new Error('The \'child\' parameter cannot be null.');

			for (var i : int = 0; i < _numChildren; i++)
				if (_children[i] === child)
					return i;

			return -1;
		}

		public function getChildByName(name : String) : ISceneNode
		{
			for (var i : int = 0; i < _numChildren; i++)
				if (_children[i].name === name)
					return _children[i];

			return null;
		}

		/**
		 * Add a child to the group.
		 *
		 * @param	scene The child to add.
		 */
		public function addChild(node : ISceneNode) : Group
		{
			return addChildAt(node, _numChildren);
		}

		/**
		 * Add a child to the group at the specified position.
		 *
		 * @param node
		 * @param position
		 * @return
		 *
		 */
		public function addChildAt(node : ISceneNode, position : uint) : Group
		{
			if (!node)
				throw new Error('Parameter \'scene\' must not be null.');

			node.parent = this;

			for (var i : int = _numChildren - 1; i > position; --i)
				_children[i] = _children[int(i - 1)];

			_children[position] = node;

			return this;
		}

		/**
		 * Remove a child from the container.
		 *
		 * @param	myChild The child to remove.
		 * @return Whether the child was actually removed or not.
		 */
		public function removeChild(child : ISceneNode) : Group
		{
			return removeChildAt(getChildIndex(child));
		}

		public function removeChildAt(position : uint) : Group
		{
			if (position >= _numChildren || position < 0)
				throw new Error('The scene node is not a child of the caller.');

			(_children[position] as ISceneNode).parent = null;

			return this;
		}

		/**
		 * Remove all the children.
		 *
		 * @return
		 *
		 */
		public function removeAllChildren() : Group
		{
			while (_numChildren)
				removeChildAt(0);

			return this;
		}

		/**
		 * Return the child at the specified position.
		 *
		 * @param position
		 * @return
		 *
		 */
		public function getChildAt(position : uint) : ISceneNode
		{
			return position < _numChildren ? _children[position] : null;
		}

		/**
		 * Returns the list of descendant scene nodes that have the specified type.
		 *
		 * @param type
		 * @param descendants
		 * @return
		 *
		 */
		public function getDescendantsByType(type 			: Class,
											 descendants 	: Vector.<ISceneNode> = null) : Vector.<ISceneNode>
		{
			descendants ||= new Vector.<ISceneNode>();

			for (var i : int = 0; i < _numChildren; ++i)
			{
				var child	: ISceneNode	= _children[i];
				var group 	: Group 		= child as Group;

				if (child is type)
					descendants.push(child);

				if (group)
					group.getDescendantsByType(type, descendants);
			}

			return descendants;
		}

		public function toString() : String
		{
			return '[' + getQualifiedClassName(this) + ' ' + name + ']';
		}

		/**
		 * Load the 3D scene corresponding to the specified URLRequest object
		 * and add it directly to the group.
		 *
		 * @param request
		 * @param options
		 * @return
		 *
		 */
		public function load(request	: URLRequest,
							 options	: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.load(request);

			return loader;
		}

		/**
		 * Load the 3D scene corresponding to the specified Class object
		 * and add it directly to the group.
		 *
		 * @param classObject
		 * @param options
		 * @return
		 *
		 */
		public function loadClass(classObject	: Class,
								  options		: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.loadClass(classObject);

			return loader;
		}

		/**
		 * Load the 3D scene corresponding to the specified ByteArray object
		 * and add it directly to the group.
		 *
		 * @param bytes
		 * @param options
		 * @return
		 *
		 */
		public function loadBytes(bytes		: ByteArray,
								  options	: ParserOptions	= null) : ILoader
		{
			var loader	: SceneLoader	= new SceneLoader(options);

			loader.complete.add(loaderCompleteHandler);
			loader.loadBytes(bytes);

			return loader;
		}

		/**
		 * Return the set of nodes matching the specified XPath query.
		 *
		 * @param xpath
		 * @return
		 *
		 */
		public function get(xpath : String) : SceneIterator
		{
			return new SceneIterator(xpath, new <ISceneNode>[this]);
		}

		private function loaderCompleteHandler(loader	: ILoader,
											   scene	: ISceneNode) : void
		{
			addChild(scene);
		}

		/**
		 * Return all the Mesh objects hit by the specified ray.
		 *
		 * @param ray
		 * @param maxDistance
		 * @return
		 *
		 */
		public function cast(ray : Ray, maxDistance : Number = Number.POSITIVE_INFINITY) : SceneIterator
		{
			var meshes		: Vector.<ISceneNode> 	= getDescendantsByType(Mesh);
			var numMeshes	: uint					= meshes.length;
			var hit			: Array					= [];
			var depth		: Vector.<Number>		= new <Number>[];
			var numItems	: uint					= 0;

			for (var i : uint = 0; i < numMeshes; ++i)
			{
				var mesh 		: Mesh		= meshes[i] as Mesh;
				var hitDepth	: Number	= mesh.cast(ray, maxDistance);

				if (hitDepth >= 0.0)
				{
					hit[numItems] = mesh;
					depth[numItems] = hitDepth;
					++numItems;
				}
			}

			if (numItems > 1)
				Sort.flashSort(depth, hit, numItems);

			return new SceneIterator(null, Vector.<ISceneNode>(hit));
		}

		override public function clone(cloneControllers : Boolean = false) : ISceneNode
		{
			var cloned : Group = new Group();

			cloned.name = name;
			cloned.transform.copyFrom(transform);

			for (var childId : uint = 0; childId < _numChildren; ++childId)
				cloned.addChildAt(getChildAt(childId).clone(), childId);

			copyControllersFrom(this, cloned, cloneControllers);

			return cloned;
		}
	}
}

use Mesh.cast() in Group.cast()

use Mesh.cast() in Group.cast()


package aerys.minko.render.geometry.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IVertexStream;
	import aerys.minko.render.geometry.stream.IndexStream;

	import flash.utils.Proxy;
	import flash.utils.flash_proxy;

	/**
	 * TriangleIterator allow per-triangle access on VertexStream objects.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class TriangleIterator extends Proxy
	{
		use namespace minko_stream;

		private var _singleReference	: Boolean			= true;

		private var _offset				: int				= 0;
		private var _index				: int				= 0;

		private var _vb					: IVertexStream		= null;
		private var _ib					: IndexStream		= null;

		private var _triangle			: TriangleReference	= null;

		public function get length() : int
		{
			return _ib ? _ib.length / 3 : _vb.numVertices / 3;
		}

		public function TriangleIterator(vertexStream 		: IVertexStream,
										   indexStream		: IndexStream,
										   singleReference	: Boolean = true)
		{
			super();

			_vb = vertexStream;
			_ib = indexStream;
			_singleReference = singleReference;
		}

		override flash_proxy function hasProperty(name : *) : Boolean
		{
			return int(name) < _ib.length / 3;
		}

		override flash_proxy function nextNameIndex(index : int) : int
		{
			index -= _offset;
			_offset = 0;

			return index < _ib.length / 3 ? index + 1 : 0;
		}

		override flash_proxy function nextName(index : int) : String
		{
			return String(index - 1);
		}

		override flash_proxy function nextValue(index : int) : *
		{
			_index = index - 1;

			if (!_singleReference || !_triangle)
				_triangle = new TriangleReference(_vb, _ib, _index);

			if (_singleReference)
			{
				_triangle._index = _index;
				_triangle.v0._index = _ib._data[int(_index * 3)];
				_triangle.v1._index = _ib._data[int(_index * 3 + 1)];
				_triangle.v2._index = _ib._data[int(_index * 3 + 2)];
				_triangle._update = TriangleReference.UPDATE_ALL;
			}

			return _triangle;
		}

		override flash_proxy function getProperty(name : *) : *
		{
			return new TriangleReference(_vb, _ib, int(name));
		}

		override flash_proxy function deleteProperty(name : *) : Boolean
		{
			var index 	: uint 	= uint(name);

			_ib.deleteTriangle(index);

			return true;
		}
	}
}

package aerys.minko.render.geometry.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IVertexStream;
	import aerys.minko.render.geometry.stream.IndexStream;

	import flash.utils.Proxy;
	import flash.utils.flash_proxy;

	/**
	 * TriangleIterator allow per-triangle access on VertexStream objects.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class TriangleIterator extends Proxy
	{
		use namespace minko_stream;

		private var _singleReference	: Boolean			= true;

		private var _offset				: int				= 0;
		private var _index				: int				= 0;

		private var _vb					: IVertexStream		= null;
		private var _ib					: IndexStream		= null;

		private var _triangle			: TriangleReference	= null;

		public function get length() : int
		{
			return _ib ? _ib.length / 3 : _vb.numVertices / 3;
		}

		public function TriangleIterator(vertexStream 		: IVertexStream,
										   indexStream		: IndexStream,
										   singleReference	: Boolean = true)
		{
			super();

			_vb = vertexStream;
			_ib = indexStream;
			_singleReference = singleReference;
		}

		override flash_proxy function hasProperty(name : *) : Boolean
		{
			return int(name) < _ib.length / 3;
		}

		override flash_proxy function nextNameIndex(index : int) : int
		{
			index -= _offset;
			_offset = 0;

			return index < _ib.length / 3 ? index + 1 : 0;
		}

		override flash_proxy function nextName(index : int) : String
		{
			return String(index - 1);
		}

		override flash_proxy function nextValue(index : int) : *
		{
			_index = index - 1;

			if (!_singleReference || !_triangle)
				_triangle = new TriangleReference(_vb, _ib, _index);

			if (_singleReference)
			{
				_triangle._index = _index;
				_triangle.v0.index = _ib.get(_index * 3);
				_triangle.v1.index = _ib.get(_index * 3 + 1);
				_triangle.v2.index = _ib.get(_index * 3 + 2);
				_triangle._update = TriangleReference.UPDATE_ALL;
			}

			return _triangle;
		}

		override flash_proxy function getProperty(name : *) : *
		{
			return new TriangleReference(_vb, _ib, int(name));
		}

		override flash_proxy function deleteProperty(name : *) : Boolean
		{
			var index 	: uint 	= uint(name);

			_ib.deleteTriangle(index);

			return true;
		}
	}
}

fix triangle iterator

fix triangle iterator


/* 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.hls {
    import org.mangui.hls.constant.HLSSeekMode;
    import org.mangui.hls.constant.HLSMaxLevelCappingMode;

    public final class HLSSettings extends Object {
        /**
         * Limit levels usable in auto-quality by the stage dimensions (width and height).
         *      true - level width and height (defined in m3u8 playlist) will be compared with the player width and height (stage.stageWidth and stage.stageHeight).
         *             Max level will be set depending on the maxLevelCappingMode option.
         *      false - levels will not be limited. All available levels could be used in auto-quality mode taking only bandwidth into consideration.
         *
         * Note: this setting is ignored in manual mode so all the levels could be selected manually.
         *
         * Default is false
         */
        public static var capLevelToStage : Boolean = false;
        /**
         * Defines the max level capping mode to the one available in HLSMaxLevelCappingMode
         *      HLSMaxLevelCappingMode.DOWNSCALE - max capped level should be the one with the dimensions equal or greater than the stage dimensions (so the video will be downscaled)
         *      HLSMaxLevelCappingMode.UPSCALE - max capped level should be the one with the dimensions equal or lower than the stage dimensions (so the video will be upscaled)
         *
         * Default is HLSMaxLevelCappingMode.DOWNSCALE
         */
        public static var maxLevelCappingMode : String = HLSMaxLevelCappingMode.DOWNSCALE;
        // // // // // // /////////////////////////////////
        //
        // org.mangui.hls.stream.HLSNetStream
        //
        // // // // // // /////////////////////////////////
        /**
         * Defines minimum buffer length in seconds before playback can start, after seeking or buffer stalling.
         *
         * Default is -1 = auto
         */
        public static var minBufferLength : Number = -1;
        /**
         * Defines maximum buffer length in seconds.
         * (0 means infinite buffering)
         *
         * Default is 120.
         */
        public static var maxBufferLength : Number = 120;
        /**
         * Defines maximum back buffer length in seconds.
         * (0 means infinite back buffering)
         *
         * Default is 30.
         */
        public static var maxBackBufferLength : Number = 30;
        /**
         * Defines low buffer length in seconds.
         * When crossing down this threshold, HLS will switch to buffering state.
         *
         * Default is 3.
         */
        public static var lowBufferLength : Number = 3;
        /**
         * Defines seek mode to one form available in HLSSeekMode class:
         *      HLSSeekMode.ACCURATE_SEEK - accurate seeking to exact requested position
         *      HLSSeekMode.KEYFRAME_SEEK - key-frame based seeking (seek to nearest key frame before requested seek position)
         *
         * Default is HLSSeekMode.KEYFRAME_SEEK.
         */
        public static var seekMode : String = HLSSeekMode.KEYFRAME_SEEK;
        /** max nb of retries for Key Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         */
        public static var keyLoadMaxRetry : int = 3;
        /** keyLoadMaxRetryTimeout

         * Maximum key retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on key request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until keyLoadMaxRetryTimeout is reached.
         *
         * Default is 64000.
         */
        public static var keyLoadMaxRetryTimeout : Number = 64000;
        /** max nb of retries for Fragment Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         */
        public static var fragmentLoadMaxRetry : int = 3;
        /** fragmentLoadMaxRetryTimeout

         * Maximum Fragment retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on fragment request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until fragmentLoadMaxRetryTimeout is reached.
         *
         * Default is 4000.
         */
        public static var fragmentLoadMaxRetryTimeout : Number = 64000;
        /** fragmentLoadSkipAfterMaxRetry

         * control behaviour in case fragment load still fails after max retry timeout
         * if set to true, fragment will be skipped and next one will be loaded.
         * If set to false, an I/O Error will be raised.
         *
         * Default is true.
         */
        public static var fragmentLoadSkipAfterMaxRetry : Boolean = true;
        /**
         * If set to true, live playlist will be flushed from URL cache before reloading
         * (this is to workaround some cache issues with some combination of Flash Player / IE version)
         *
         * Default is false
         */
        public static var flushLiveURLCache : Boolean = false;
        /** max nb of retries for Manifest Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         */
        public static var manifestLoadMaxRetry : int = -1;
        /** manifestLoadMaxRetryTimeout

         * Maximum Manifest retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on fragment request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until manifestLoadMaxRetryTimeout is reached.
         *
         * Default is 64000.
         */
        public static var manifestLoadMaxRetryTimeout : Number = 64000;
        /**
         * If greater than 0, specifies the preferred bitrate.
         * If -1, and startFromLevel is not specified, automatic start level selection will be used.
         * This parameter, if set, will take priority over startFromLevel.
         */
        public static var startFromBitrate : Number = -1;
        /** start level :
         *  from 0 to 1 : indicates the "normalized" preferred level. As such, if it is 0.5, the closest to the middle bitrate will be selected and used first.
         * -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)
         * -2 : playback will start from the first level appearing in Manifest (not sorted by bitrate)
         */
        public static var startFromLevel : Number = -1;
        /** seek level :
         *  from 0 to 1 : indicates the "normalized" preferred bitrate. As such, if it is 0.5, the closest to the middle bitrate will be selected and used first.
         * -1 : automatic start level selection, keep previous level matching previous download bandwidth
         */
        public static var seekFromLevel : Number = -1;
        /** use hardware video decoder :
         *  it will set NetStream.useHardwareDecoder
         *  refer to http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#useHardwareDecoder
         */
        public static var useHardwareVideoDecoder : Boolean = false;
        /**
         * Defines whether INFO level log messages will will appear in the console
         * Default is true.
         */
        public static var logInfo : Boolean = true;
        /**
         * Defines whether DEBUG level log messages will will appear in the console
         * Default is false.
         */
        public static var logDebug : Boolean = false;
        /**
         * Defines whether DEBUG2 level log messages will will appear in the console
         * Default is false.
         */
        public static var logDebug2 : Boolean = false;
        /**
         * Defines whether WARN level log messages will will appear in the console
         * Default is true.
         */
        public static var logWarn : Boolean = true;
        /**
         * Defines whether ERROR level log messages will will appear in the console
         * Default is true.
         */
        public static var logError : Boolean = true;
    }
}

/* 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.hls {
    import org.mangui.hls.constant.HLSSeekMode;
    import org.mangui.hls.constant.HLSMaxLevelCappingMode;

    public final class HLSSettings extends Object {
        /**
         * capLevelToStage
         *
         * Limit levels usable in auto-quality by the stage dimensions (width and height).
         *      true - level width and height (defined in m3u8 playlist) will be compared with the player width and height (stage.stageWidth and stage.stageHeight).
         *             Max level will be set depending on the maxLevelCappingMode option.
         *      false - levels will not be limited. All available levels could be used in auto-quality mode taking only bandwidth into consideration.
         *
         * Note: this setting is ignored in manual mode so all the levels could be selected manually.
         *
         * Default is false
         */
        public static var capLevelToStage : Boolean = false;

        /**
         * maxLevelCappingMode
         *
         * Defines the max level capping mode to the one available in HLSMaxLevelCappingMode
         *      HLSMaxLevelCappingMode.DOWNSCALE - max capped level should be the one with the dimensions equal or greater than the stage dimensions (so the video will be downscaled)
         *      HLSMaxLevelCappingMode.UPSCALE - max capped level should be the one with the dimensions equal or lower than the stage dimensions (so the video will be upscaled)
         *
         * Default is HLSMaxLevelCappingMode.DOWNSCALE
         */
        public static var maxLevelCappingMode : String = HLSMaxLevelCappingMode.DOWNSCALE;

        // // // // // // /////////////////////////////////
        //
        // org.mangui.hls.stream.HLSNetStream
        //
        // // // // // // /////////////////////////////////
        /**
         * minBufferLength
         *
         * Defines minimum buffer length in seconds before playback can start, after seeking or buffer stalling.
         *
         * Default is -1 = auto
         */
        public static var minBufferLength : Number = -1;

        /**
         * maxBufferLength
         *
         * Defines maximum buffer length in seconds.
         * (0 means infinite buffering)
         *
         * Default is 120
         */
        public static var maxBufferLength : Number = 120;

        /**
         * maxBackBufferLength
         *
         * Defines maximum back buffer length in seconds.
         * (0 means infinite back buffering)
         *
         * Default is 30
         */
        public static var maxBackBufferLength : Number = 30;

        /**
         * lowBufferLength
         *
         * Defines low buffer length in seconds.
         * When crossing down this threshold, HLS will switch to buffering state.
         *
         * Default is 3
         */
        public static var lowBufferLength : Number = 3;

        /**
         * seekMode
         *
         * Defines seek mode to one form available in HLSSeekMode class:
         *      HLSSeekMode.ACCURATE_SEEK - accurate seeking to exact requested position
         *      HLSSeekMode.KEYFRAME_SEEK - key-frame based seeking (seek to nearest key frame before requested seek position)
         *
         * Default is HLSSeekMode.KEYFRAME_SEEK
         */
        public static var seekMode : String = HLSSeekMode.KEYFRAME_SEEK;

        /**
         * keyLoadMaxRetry
         *
         * Max nb of retries for Key Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         *
         * Default is 3
         */
        public static var keyLoadMaxRetry : int = 3;

        /**
         * keyLoadMaxRetryTimeout
         *
         * Maximum key retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on key request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until keyLoadMaxRetryTimeout is reached.
         *
         * Default is 64000.
         */
        public static var keyLoadMaxRetryTimeout : Number = 64000;

        /**
         * fragmentLoadMaxRetry
         *
         * Max number of retries for Fragment Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         *
         * Default is 3
         */
        public static var fragmentLoadMaxRetry : int = 3;

        /**
         * fragmentLoadMaxRetryTimeout
         *
         * Maximum Fragment retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on fragment request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until fragmentLoadMaxRetryTimeout is reached.
         *
         * Default is 4000
         */
        public static var fragmentLoadMaxRetryTimeout : Number = 4000

        /**
         * fragmentLoadSkipAfterMaxRetry
         *
         * control behaviour in case fragment load still fails after max retry timeout
         * if set to true, fragment will be skipped and next one will be loaded.
         * If set to false, an I/O Error will be raised.
         *
         * Default is true.
         */
        public static var fragmentLoadSkipAfterMaxRetry : Boolean = true;

        /**
         * flushLiveURLCache
         *
         * If set to true, live playlist will be flushed from URL cache before reloading
         * (this is to workaround some cache issues with some combination of Flash Player / IE version)
         *
         * Default is false
         */
        public static var flushLiveURLCache : Boolean = false;

        /**
         * manifestLoadMaxRetry
         *
         * max nb of retries for Manifest Loading in case I/O errors are met,
         *      0, means no retry, error will be triggered automatically
         *     -1 means infinite retry
         */
        public static var manifestLoadMaxRetry : int = -1;

        /**
         * manifestLoadMaxRetryTimeout
         *
         * Maximum Manifest retry timeout (in milliseconds) in case I/O errors are met.
         * Every fail on fragment request, player will exponentially increase the timeout to try again.
         * It starts waiting 1 second (1000ms), than 2, 4, 8, 16, until manifestLoadMaxRetryTimeout is reached.
         *
         * Default is 64000
         */
        public static var manifestLoadMaxRetryTimeout : Number = 64000;

        /**
         * startFromBitrate
         *
         * If greater than 0, specifies the preferred bitrate.
         * If -1, and startFromLevel is not specified, automatic start level selection will be used.
         * This parameter, if set, will take priority over startFromLevel.
         *
         * Default is -1
         */
        public static var startFromBitrate : Number = -1;

        /**
         * startFromLevel
         *
         * start level :
         *  from 0 to 1 : indicates the "normalized" preferred level. As such, if it is 0.5, the closest to the middle bitrate will be selected and used first.
         * -1 : automatic start level selection, playback will start from level matching download bandwidth (determined from download of first segment)
         * -2 : playback will start from the first level appearing in Manifest (not sorted by bitrate)
         *
         * Default is -1
         */
        public static var startFromLevel : Number = -1;

        /**
         * seekFromLevel
         *
         * Seek level:
         *  from 0 to 1: indicates the "normalized" preferred bitrate. As such, if it is 0.5, the closest to the middle bitrate will be selected and used first.
         * -1 : automatic start level selection, keep previous level matching previous download bandwidth
         *
         * Default is -1
         */
        public static var seekFromLevel : Number = -1;

        /**
         * useHardwareVideoDecoder
         *
         * Use hardware video decoder:
         *  it will set NetStream.useHardwareDecoder
         *  refer to http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#useHardwareDecoder
         *
         * Default is false
         */
        public static var useHardwareVideoDecoder : Boolean = false;

        /**
         * logInfo
         *
         * Defines whether INFO level log messages will will appear in the console
         *
         * Default is true
         */
        public static var logInfo : Boolean = true;

        /**
         * logDebug
         *
         * Defines whether DEBUG level log messages will will appear in the console
         *
         * Default is false
         */
        public static var logDebug : Boolean = false;

        /**
         * logDebug2
         *
         * Defines whether DEBUG2 level log messages will will appear in the console
         *
         * Default is false
         */
        public static var logDebug2 : Boolean = false;

        /**
         * logWarn
         *
         * Defines whether WARN level log messages will will appear in the console
         *
         * Default is true
         */
        public static var logWarn : Boolean = true;

        /**
         * logError
         *
         * Defines whether ERROR level log messages will will appear in the console
         *
         * Default is true
         */
        public static var logError : Boolean = true;
    }
}

Format settings in consistent and readable manner

Remove inconsistencies in formatting. Fix differences between defaults in descriptions and setting values.


/*
    Weave (Web-based Analysis and Visualization Environment)
    Copyright (C) 2008-2011 University of Massachusetts Lowell

    This file is a part of Weave.

    Weave is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License, Version 3,
    as published by the Free Software Foundation.

    Weave is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/

package weave.utils
{
	import flash.utils.Proxy;
	import flash.utils.flash_proxy;
	import flash.utils.getQualifiedClassName;

	/**
	 * This is a Proxy object that wraps function calls in a way that allows method chaining (obj.f(1).g(2).h(3)).
	 * Multiple objects can be wrapped in a single MethodChainProxy object.
	 * In that case, method calls will use the first object with a matching property name.
	 * If a wrapped function returns a value, it can be accessed using valueOf():  obj.f(1).g(2).valueOf()
	 * Non-function properties are automatically wrapped in setter/getter functions that will set the value if given one parameter
	 * and get the value if given zero parameters.
	 *
	 * @example
	 * <listing version="3.0">
	 * var shape:Shape = new Shape();
	 * var graphicsChain:MethodChainProxy = new MethodChainProxy(shape, shape.graphics);
	 *
	 * this.rawChildren.addChild(shape);
	 *
	 * graphicsChain.lineStyle(1,1,1)
	 *  .moveTo(0,0)
	 *  .lineTo(10,10)
	 *  .lineTo(10,0)
	 *  .lineTo(0,0)
	 *  .x(20)
	 *  .y(40)
	 *  .scaleX(3)
	 *  .scaleY(4);
	 *
	 * trace( 'Width of shape is:', graphicsChain.width() );
	 * trace( 'getRect() returns:', graphicsChain.getRect(this).valueOf() );
	 * </listing>
	 *
	 * @author adufilie
	 */
	public dynamic class MethodChainProxy extends Proxy
	{
		/**
		 * Constructor.
		 * @param object The primary object to be proxied by chainable method wrappers, or null if you wish to specify objects in an Array in the moreObjects parameter.
		 * @param moreObjects Additional objects to be checked in order in case properties/methods do not exist on the primary object.
		 *                    You may specify a single Array as the moreObjects parameter if the primary object parameter is set to null.
		 */
		public function MethodChainProxy(primaryObject:Object, ...moreObjects):void
		{
			if (primaryObject == null && moreObjects.length == 1 && moreObjects[0] is Array)
				moreObjects = (moreObjects[0] as Array).concat();
			else
				moreObjects.unshift(primaryObject);

			_objectsToCheck = moreObjects;

			_classNames = _objectsToCheck.map(function(o:*):* { return getQualifiedClassName(o); });

			_thisQName = getQualifiedClassName(this);
			var i:int = _classNames.indexOf('Object');
			if (i >= 0)
				_classNames[i] = _thisQName;
			else
				_classNames.push(_thisQName);
		}

		private var _thisQName:String;
		private var _objectsToCheck:Array;
		private var _classNames:Array;
		private var _wrappers:Object = {};
		private var _hosts:Object = {};
		private var _result:*;

		/**
		 * Gets the value returned from the last function call.
		 */
		public function valueOf():*
		{
			return _result;
		}

		private function _getWrapper(host:Object, property:String):*
		{
			// used cached wrapper function if it exists
			if (_wrappers.hasOwnProperty(property))
				return _wrappers[property] as Function;

			// cache a new wrapper function
			var wrapper:*;
			if (host[property] is Function)
				wrapper = _newFunctionWrapper(host, property);
			else
				wrapper = _newSetterGetter(host, property);

			return _wrappers[property] = wrapper;
		}

		private function _newFunctionWrapper(host:Object, property:String):Function
		{
			// create a wrapper function that supports method chaining
			var isProxy:Boolean = host is Proxy;
			var _this:* = this;
			return function(...args):* {
				_this._result = undefined; // in case error is thrown

				if (isProxy)
					_this._result = (host as Proxy).flash_proxy::callProperty(property, args);
				else
					_this._result = host[property].apply(host, args);

				return _this; // return MethodChainProxy to allow method chaining
			};
		}

		private function _newSetterGetter(host:Object, property:String):Function
		{
			// create a property setter/getter
			var _this:* = this;
			return function(...args):* {
				_this._result = undefined; // in case error is thrown
				if (args.length == 0)
				{
					// 'getter' mode - return the value
					return _this._result = host[property];
				}
				if (args.length == 1)
				{
					// 'setter' mode - allows method chaining
					_this._result = host[property] = args[0];
					return _this;
				}
				throw new Error(_thisQName + '.' + property + '(): Invalid number of arguments.  Expecting 0 or 1.');
			};
		}

		private function _throwError(propertyName:String):void
		{
			throw new Error('There is no property named "' + propertyName + '" on ' + _classNames.join(' or '));
		}

		private function _findHost(name:*, checkBuiltIns:Boolean):Object
		{
			var host:Object;

			for each (host in _objectsToCheck)
				if (host.hasOwnProperty(name))
					return _hosts[name] = host;

			if (checkBuiltIns)
				for each (host in _objectsToCheck)
					if (name in host)
						return _hosts[name] = host;

			return null;
		}

		override flash_proxy function hasProperty(name:*):Boolean
		{
			if (_hosts.hasOwnProperty(name) || _findHost(name, false))
				return true;
			return false;
		}

		override flash_proxy function getProperty(name:*):*
		{
			if (name == 'valueOf')
				return valueOf as Function;

			if (_wrappers.hasOwnProperty(name))
				return _wrappers[name];

			if (_hosts.hasOwnProperty(name) || _findHost(name, true))
				return _getWrapper(_hosts[name], name);

			_throwError(name);
		}

		override flash_proxy function setProperty(name:*, value:*):void
		{
			if (_hosts.hasOwnProperty(name) || _findHost(name, true))
			{
				_hosts[name][name] = value;
				return;
			}
			_throwError(name);
		}

		override flash_proxy function callProperty(name:*, ...parameters):*
		{
			var method:*;
			if (_wrappers.hasOwnProperty(name))
				method = _wrappers[name];
			else
				method = flash_proxy::getProperty(name);

			try
			{
				return method.apply(_hosts[name], parameters);
			}
			catch (e:Error)
			{
				e.message = _thisQName + '.' + name + '(): ' + e.message;
				throw e;
			}
		}
	}
}

/*
    Weave (Web-based Analysis and Visualization Environment)
    Copyright (C) 2008-2011 University of Massachusetts Lowell

    This file is a part of Weave.

    Weave is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License, Version 3,
    as published by the Free Software Foundation.

    Weave is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Weave.  If not, see <http://www.gnu.org/licenses/>.
*/

package weave.utils
{
	import flash.utils.Proxy;
	import flash.utils.flash_proxy;
	import flash.utils.getQualifiedClassName;

	/**
	 * This is a Proxy object that wraps function calls in a way that allows method chaining (obj.f(1).g(2).h(3)).
	 * Multiple objects can be wrapped in a single MethodChainProxy object.
	 * In that case, method calls will use the first object with a matching property name.
	 * If a wrapped function returns a value, it can be accessed using valueOf():  obj.f(1).g(2).valueOf()
	 * Non-function properties are automatically wrapped in setter/getter functions that will set the value if given one parameter
	 * and get the value if given zero parameters.
	 *
	 * @example
	 * <listing version="3.0">
	 * var shape:Shape = new Shape();
	 * var graphicsChain:MethodChainProxy = new MethodChainProxy(shape, shape.graphics);
	 *
	 * this.rawChildren.addChild(shape);
	 *
	 * graphicsChain.lineStyle(1,1,1)
	 *  .moveTo(0,0)
	 *  .lineTo(10,10)
	 *  .lineTo(10,0)
	 *  .lineTo(0,0)
	 *  .x(20)
	 *  .y(40)
	 *  .scaleX(3)
	 *  .scaleY(4);
	 *
	 * trace( 'Width of shape is:', graphicsChain.width() );
	 * trace( 'getRect() returns:', graphicsChain.getRect(this).valueOf() );
	 * </listing>
	 *
	 * @author adufilie
	 */
	public dynamic class MethodChainProxy extends Proxy
	{
		/**
		 * Constructor.
		 * @param object The primary object to be proxied by chainable method wrappers, or null if you wish to specify objects in an Array in the moreObjects parameter.
		 * @param moreObjects Additional objects to be checked in order in case properties/methods do not exist on the primary object.
		 *                    You may specify a single Array as the moreObjects parameter if the primary object parameter is set to null.
		 */
		public function MethodChainProxy(primaryObject:Object, ...moreObjects):void
		{
			if (primaryObject == null && moreObjects.length == 1 && moreObjects[0] is Array)
				moreObjects = (moreObjects[0] as Array).concat();
			else
				moreObjects.unshift(primaryObject);

			_objectsToCheck = moreObjects;

			_classNames = _objectsToCheck.map(function(o:*, ..._):* { return getQualifiedClassName(o); });

			_thisQName = getQualifiedClassName(this);
			var i:int = _classNames.indexOf('Object');
			if (i >= 0)
				_classNames[i] = _thisQName;
			else
				_classNames.push(_thisQName);
		}

		private var _thisQName:String;
		private var _objectsToCheck:Array;
		private var _classNames:Array;
		private var _wrappers:Object = {};
		private var _hosts:Object = {};
		private var _result:*;

		/**
		 * Gets the value returned from the last function call.
		 */
		public function valueOf():*
		{
			return _result;
		}

		private function _getWrapper(host:Object, property:String):*
		{
			// used cached wrapper function if it exists
			if (_wrappers.hasOwnProperty(property))
				return _wrappers[property] as Function;

			// cache a new wrapper function
			var wrapper:*;
			if (host[property] is Function)
				wrapper = _newFunctionWrapper(host, property);
			else
				wrapper = _newSetterGetter(host, property);

			return _wrappers[property] = wrapper;
		}

		private function _newFunctionWrapper(host:Object, property:String):Function
		{
			// create a wrapper function that supports method chaining
			var isProxy:Boolean = host is Proxy;
			var _this:* = this;
			return function(...args):* {
				_this._result = undefined; // in case error is thrown

				if (isProxy)
					_this._result = (host as Proxy).flash_proxy::callProperty(property, args);
				else
					_this._result = host[property].apply(host, args);

				return _this; // return MethodChainProxy to allow method chaining
			};
		}

		private function _newSetterGetter(host:Object, property:String):Function
		{
			// create a property setter/getter
			var _this:* = this;
			return function(...args):* {
				_this._result = undefined; // in case error is thrown
				if (args.length == 0)
				{
					// 'getter' mode - return the value
					return _this._result = host[property];
				}
				if (args.length == 1)
				{
					// 'setter' mode - allows method chaining
					_this._result = host[property] = args[0];
					return _this;
				}
				throw new Error(_thisQName + '.' + property + '(): Invalid number of arguments.  Expecting 0 or 1.');
			};
		}

		private function _throwError(propertyName:String):void
		{
			throw new Error('There is no property named "' + propertyName + '" on ' + _classNames.join(' or '));
		}

		private function _findHost(name:*, checkBuiltIns:Boolean):Object
		{
			var host:Object;

			for each (host in _objectsToCheck)
				if (host.hasOwnProperty(name))
					return _hosts[name] = host;

			if (checkBuiltIns)
				for each (host in _objectsToCheck)
					if (name in host)
						return _hosts[name] = host;

			return null;
		}

		override flash_proxy function hasProperty(name:*):Boolean
		{
			if (_hosts.hasOwnProperty(name) || _findHost(name, false))
				return true;
			return false;
		}

		override flash_proxy function getProperty(name:*):*
		{
			if (name == 'valueOf')
				return valueOf as Function;

			if (_wrappers.hasOwnProperty(name))
				return _wrappers[name];

			if (_hosts.hasOwnProperty(name) || _findHost(name, true))
				return _getWrapper(_hosts[name], name);

			_throwError(name);
		}

		override flash_proxy function setProperty(name:*, value:*):void
		{
			if (_hosts.hasOwnProperty(name) || _findHost(name, true))
			{
				_hosts[name][name] = value;
				return;
			}
			_throwError(name);
		}

		override flash_proxy function callProperty(name:*, ...parameters):*
		{
			var method:*;
			if (_wrappers.hasOwnProperty(name))
				method = _wrappers[name];
			else
				method = flash_proxy::getProperty(name);

			try
			{
				return method.apply(_hosts[name], parameters);
			}
			catch (e:Error)
			{
				e.message = _thisQName + '.' + name + '(): ' + e.message;
				throw e;
			}
		}
	}
}

add ..._

add ..._