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

	import org.apache.flex.events.ValueChangeEvent;
	import org.apache.flex.events.EventDispatcher;

	public class SimpleCSSValuesImpl extends EventDispatcher implements IValuesImpl
	{
		public function SimpleCSSValuesImpl()
		{
			super();
		}

        private var mainClass:Object;

		private var conditionCombiners:Object;

        public function init(mainClass:Object):void
        {
			var styleClassName:String;
			var c:Class;
			if (!values)
			{
				values = {};
	            this.mainClass = mainClass;
	            var mainClassName:String = getQualifiedClassName(mainClass);
				styleClassName = "_" + mainClassName + "_Styles";
				c = ApplicationDomain.currentDomain.getDefinition(styleClassName) as Class;
			}
			else
			{
				var className:String = getQualifiedClassName(mainClass);
				c = ApplicationDomain.currentDomain.getDefinition(className) as Class;
			}
            generateCSSStyleDeclarations(c["factoryFunctions"], c["data"]);
        }

        public function generateCSSStyleDeclarations(factoryFunctions:Object, arr:Array):void
        {
			if (factoryFunctions == null)
				return;
			if (arr == null)
				return;

            var declarationName:String = "";
            var segmentName:String = "";
            var n:int = arr.length;
            for (var i:int = 0; i < n; i++)
            {
                var className:int = arr[i];
                if (className == CSSClass.CSSSelector)
                {
                    var selectorName:String = arr[++i];
                    segmentName = selectorName + segmentName;
                    if (declarationName != "")
                        declarationName += " ";
                    declarationName += segmentName;
                    segmentName = "";
                }
                else if (className == CSSClass.CSSCondition)
                {
					if (!conditionCombiners)
					{
						conditionCombiners = {};
						conditionCombiners["class"] = ".";
						conditionCombiners["id"] = "#";
						conditionCombiners["pseudo"] = ':';
					}
					var conditionType:String = arr[++i];
					var conditionName:String = arr[++i];
					segmentName = segmentName + conditionCombiners[conditionType] + conditionName;
                }
                else if (className == CSSClass.CSSStyleDeclaration)
                {
                    var factoryName:int = arr[++i]; // defaultFactory or factory
                    var defaultFactory:Boolean = factoryName == CSSFactory.DefaultFactory;
                    /*
                    if (defaultFactory)
                    {
                        mergedStyle = styleManager.getMergedStyleDeclaration(declarationName);
                        style = new CSSStyleDeclaration(selector, styleManager, mergedStyle == null);
                    }
                    else
                    {
                        style = styleManager.getStyleDeclaration(declarationName);
                        if (!style)
                        {
                            style = new CSSStyleDeclaration(selector, styleManager, mergedStyle == null);
                            if (factoryName == CSSFactory.Override)
                                newSelectors.push(style);
                        }
                    }
                    */
                    var finalName:String;
                    var valuesFunction:Function;
                    var valuesObject:Object;
                    if (defaultFactory)
                    {
                        valuesFunction = factoryFunctions[declarationName];
                        valuesObject = new valuesFunction();
                        finalName = fixNames(declarationName);
                        values[finalName] = valuesObject;
                    }
                    else
                    {
                        valuesFunction = factoryFunctions[declarationName];
                        valuesObject = new valuesFunction();
                        var o:Object = values[declarationName];
                        finalName = fixNames(declarationName);
                        if (o == null)
                            values[finalName] = valuesObject;
                        else
                        {
                            valuesFunction.prototype = o;
                            values[finalName] = new valuesFunction();
                        }
                    }
                    declarationName = "";
                }
            }

        }

        private function fixNames(s:String):String
        {
			if (s == "")
				return "*";

            var arr:Array = s.split(" ");
            var n:int = arr.length;
            for (var i:int = 0; i < n; i++)
            {
                var segmentName:String = arr[i];
				if (segmentName.charAt(0) == "#" || segmentName.charAt(0) == ".")
					continue;

                var c:int = segmentName.lastIndexOf(".");
                if (c > -1)	// it is 0 for class selectors
                {
                    segmentName = segmentName.substr(0, c) + "::" + segmentName.substr(c + 1);
                    arr[i] = segmentName;
                }
            }
            return arr.join(" ");
        }

        public var values:Object;

		public function getValue(thisObject:Object, valueName:String, state:String = null, attrs:Object = null):*
		{
            var c:int = valueName.indexOf("-");
            while (c != -1)
            {
                valueName = valueName.substr(0, c) +
                    valueName.charAt(c + 1).toUpperCase() +
                    valueName.substr(c + 2);
                c = valueName.indexOf("-");
            }

            var value:*;
			var o:Object;
			var className:String;
			var selectorName:String;

			if ("className" in thisObject)
			{
				className = thisObject.className;
				if (state)
				{
					selectorName = className + ":" + state;
					o = values["." + selectorName];
					if (o)
					{
						value = o[valueName];
						if (value !== undefined)
							return value;
					}
				}

				o = values["." + className];
				if (o)
				{
					value = o[valueName];
					if (value !== undefined)
						return value;
				}
			}

			className = getQualifiedClassName(thisObject);
			while (className != "Object")
			{
				if (state)
				{
					selectorName = className + ":" + state;
					o = values[selectorName];
					if (o)
					{
						value = o[valueName];
						if (value !== undefined)
							return value;
					}
				}

	            o = values[className];
	            if (o)
	            {
	                value = o[valueName];
	                if (value !== undefined)
	                    return value;
	            }
				className = getQualifiedSuperclassName(thisObject);
				thisObject = getDefinitionByName(className);
			}
            o = values["global"];
            if (o)
            {
    			value = o[valueName];
    			if (value !== undefined)
    				return value;
            }
			o = values["*"];
			if(o)
			{
				return o[valueName];
			}
			return null;
		}

		public function setValue(thisObject:Object, valueName:String, value:*):void
		{
            var c:int = valueName.indexOf("-");
            while (c != -1)
            {
                valueName = valueName.substr(0, c) +
                    valueName.charAt(c + 1).toUpperCase() +
                    valueName..substr(c + 2);
                c = valueName.indexOf("-");
            }
			var oldValue:Object = values[valueName];
			if (oldValue != value)
			{
				values[valueName] = value;
				dispatchEvent(new ValueChangeEvent(ValueChangeEvent.VALUE_CHANGE, false, false, oldValue, value));
			}
		}

        public function getInstance(valueName:String):Object
        {
            var o:Object = values["global"];
            if (o is Class)
            {
                o[valueName] = new o[valueName]();
                if (o[valueName] is IDocument)
                    o[valueName].setDocument(mainClass);
            }
            return o[valueName];
        }
	}
}

class CSSClass
{
    public static const CSSSelector:int = 0;
    public static const CSSCondition:int = 1;
    public static const CSSStyleDeclaration:int = 2;
}

class CSSFactory
{
    public static const DefaultFactory:int = 0;
    public static const Factory:int = 1;
    public static const Override:int = 2;
}

class CSSDataType
{
    public static const Native:int = 0;
    public static const Definition:int = 1;
}

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

	import org.apache.flex.events.EventDispatcher;
	import org.apache.flex.events.ValueChangeEvent;

	public class SimpleCSSValuesImpl extends EventDispatcher implements IValuesImpl
	{
		public function SimpleCSSValuesImpl()
		{
			super();
		}

        private var mainClass:Object;

		private var conditionCombiners:Object;

        public function init(mainClass:Object):void
        {
			var styleClassName:String;
			var c:Class;
			if (!values)
			{
				values = {};
	            this.mainClass = mainClass;
	            var mainClassName:String = getQualifiedClassName(mainClass);
				styleClassName = "_" + mainClassName + "_Styles";
				c = ApplicationDomain.currentDomain.getDefinition(styleClassName) as Class;
			}
			else
			{
				var className:String = getQualifiedClassName(mainClass);
				c = ApplicationDomain.currentDomain.getDefinition(className) as Class;
			}
            generateCSSStyleDeclarations(c["factoryFunctions"], c["data"]);
        }

        public function generateCSSStyleDeclarations(factoryFunctions:Object, arr:Array):void
        {
			if (factoryFunctions == null)
				return;
			if (arr == null)
				return;

            var declarationName:String = "";
            var segmentName:String = "";
            var n:int = arr.length;
            for (var i:int = 0; i < n; i++)
            {
                var className:int = arr[i];
                if (className == CSSClass.CSSSelector)
                {
                    var selectorName:String = arr[++i];
                    segmentName = selectorName + segmentName;
                    if (declarationName != "")
                        declarationName += " ";
                    declarationName += segmentName;
                    segmentName = "";
                }
                else if (className == CSSClass.CSSCondition)
                {
					if (!conditionCombiners)
					{
						conditionCombiners = {};
						conditionCombiners["class"] = ".";
						conditionCombiners["id"] = "#";
						conditionCombiners["pseudo"] = ':';
					}
					var conditionType:String = arr[++i];
					var conditionName:String = arr[++i];
					segmentName = segmentName + conditionCombiners[conditionType] + conditionName;
                }
                else if (className == CSSClass.CSSStyleDeclaration)
                {
                    var factoryName:int = arr[++i]; // defaultFactory or factory
                    var defaultFactory:Boolean = factoryName == CSSFactory.DefaultFactory;
                    /*
                    if (defaultFactory)
                    {
                        mergedStyle = styleManager.getMergedStyleDeclaration(declarationName);
                        style = new CSSStyleDeclaration(selector, styleManager, mergedStyle == null);
                    }
                    else
                    {
                        style = styleManager.getStyleDeclaration(declarationName);
                        if (!style)
                        {
                            style = new CSSStyleDeclaration(selector, styleManager, mergedStyle == null);
                            if (factoryName == CSSFactory.Override)
                                newSelectors.push(style);
                        }
                    }
                    */
                    var mq:String = null;
                    var o:Object;
                    if (i < n - 2)
                    {
                        // peek ahead to see if there is a media query
                        if (arr[i + 1] == CSSClass.CSSMediaQuery)
                        {
                            mq = arr[i + 2];
                            i += 2;
                            declarationName = mq + "_" + declarationName;
                        }
                    }
                    var finalName:String;
                    var valuesFunction:Function;
                    var valuesObject:Object;
                    if (defaultFactory)
                    {
                        valuesFunction = factoryFunctions[declarationName];
                        valuesObject = new valuesFunction();
                    }
                    else
                    {
                        valuesFunction = factoryFunctions[declarationName];
                        valuesObject = new valuesFunction();
                    }
                    if (isValidStaticMediaQuery(mq))
                    {
                        finalName = fixNames(declarationName, mq);
                        o = values[finalName];
                        if (o == null)
                            values[finalName] = valuesObject;
                        else
                        {
                            valuesFunction.prototype = o;
                            values[finalName] = new valuesFunction();
                        }
                    }
                    declarationName = "";
                }
            }

        }

        private function isValidStaticMediaQuery(mq:String):Boolean
        {
            if (mq == null)
                return true;

            if (mq == "-flex-flash")
                return true;

            // TODO: (aharui) other media query

            return false;
        }

        private function fixNames(s:String, mq:String):String
        {
            if (mq != null)
                s = s.substr(mq.length + 1); // 1 more for the hyphen

			if (s == "")
				return "*";

            var arr:Array = s.split(" ");
            var n:int = arr.length;
            for (var i:int = 0; i < n; i++)
            {
                var segmentName:String = arr[i];
				if (segmentName.charAt(0) == "#" || segmentName.charAt(0) == ".")
					continue;

                var c:int = segmentName.lastIndexOf(".");
                if (c > -1)	// it is 0 for class selectors
                {
                    segmentName = segmentName.substr(0, c) + "::" + segmentName.substr(c + 1);
                    arr[i] = segmentName;
                }
            }
            return arr.join(" ");
        }

        public var values:Object;

		public function getValue(thisObject:Object, valueName:String, state:String = null, attrs:Object = null):*
		{
            var c:int = valueName.indexOf("-");
            while (c != -1)
            {
                valueName = valueName.substr(0, c) +
                    valueName.charAt(c + 1).toUpperCase() +
                    valueName.substr(c + 2);
                c = valueName.indexOf("-");
            }

            var value:*;
			var o:Object;
			var className:String;
			var selectorName:String;

			if ("className" in thisObject)
			{
				className = thisObject.className;
				if (state)
				{
					selectorName = className + ":" + state;
					o = values["." + selectorName];
					if (o)
					{
						value = o[valueName];
						if (value !== undefined)
							return value;
					}
				}

				o = values["." + className];
				if (o)
				{
					value = o[valueName];
					if (value !== undefined)
						return value;
				}
			}

			className = getQualifiedClassName(thisObject);
			while (className != "Object")
			{
				if (state)
				{
					selectorName = className + ":" + state;
					o = values[selectorName];
					if (o)
					{
						value = o[valueName];
						if (value !== undefined)
							return value;
					}
				}

	            o = values[className];
	            if (o)
	            {
	                value = o[valueName];
	                if (value !== undefined)
	                    return value;
	            }
				className = getQualifiedSuperclassName(thisObject);
				thisObject = getDefinitionByName(className);
			}
            o = values["global"];
            if (o)
            {
    			value = o[valueName];
    			if (value !== undefined)
    				return value;
            }
			o = values["*"];
			if(o)
			{
				return o[valueName];
			}
			return null;
		}

		public function setValue(thisObject:Object, valueName:String, value:*):void
		{
            var c:int = valueName.indexOf("-");
            while (c != -1)
            {
                valueName = valueName.substr(0, c) +
                    valueName.charAt(c + 1).toUpperCase() +
                    valueName..substr(c + 2);
                c = valueName.indexOf("-");
            }
			var oldValue:Object = values[valueName];
			if (oldValue != value)
			{
				values[valueName] = value;
				dispatchEvent(new ValueChangeEvent(ValueChangeEvent.VALUE_CHANGE, false, false, oldValue, value));
			}
		}

        public function getInstance(valueName:String):Object
        {
            var o:Object = values["global"];
            if (o is Class)
            {
                o[valueName] = new o[valueName]();
                if (o[valueName] is IDocument)
                    o[valueName].setDocument(mainClass);
            }
            return o[valueName];
        }
	}
}

class CSSClass
{
    public static const CSSSelector:int = 0;
    public static const CSSCondition:int = 1;
    public static const CSSStyleDeclaration:int = 2;
    public static const CSSMediaQuery:int = 3;
}

class CSSFactory
{
    public static const DefaultFactory:int = 0;
    public static const Factory:int = 1;
    public static const Override:int = 2;
}

class CSSDataType
{
    public static const Native:int = 0;
    public static const Definition:int = 1;
}

add limited media query check for -flex-flash. More MQ processing needed eventually


/*
# Copyright (c) 2008-2010 rPath, Inc.
#
# This program is distributed under the terms of the MIT License as found
# in a file called LICENSE. If it is not present, the license
# is always available at http://www.opensource.org/licenses/mit-license.php.
#
# This program 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 MIT License for full details.
#
*/

package com.rpath.xobj
{
import flash.events.EventDispatcher;

public class FilterTerm extends EventDispatcher
{
    public function FilterTerm(name:String,
                               value:String,
                               operator:String = EQUAL)
    {
        super();

        this.name = name;
        this.operator = operator;
        this.value = value;
    }

    /**
     * The field/property to filter on (LHS)
     */
    public var name:String;

    /**
     * The logical operator to apply (see static consts below)
     */
    public var operator:String;

    /**
     * The value to test the field against (RHS)
     */
    public var value:String;

    public static const EQUAL:String = "EQUALS";
    public static const NOT_EQUAL:String = "NOT_EQUALS";
    public static const LESS_THAN:String = "LESS_THAN";
    public static const LESS_THAN_OR_EQUAL:String = "LESS_THAN_OR_EQUAL";
    public static const GREATER_THAN:String = "GREATER_THAN";
    public static const GREATER_THAN_OR_EQUAL:String = "GREATER_THAN_OR_EQUAL";
    public static const LIKE:String = "LIKE";
    public static const NOT_LIKE:String = "NOT_LIKE";
    public static const IN:String = "IN";
    public static const NOT_IN:String = "NOT_IN";
    public static const MATCHING:String = "MATCHING";
    public static const NOT_MATCHING:String = "NOT_MATCHING";

    public static const IS:String = "IS";
    public static const IS_NOT:String = "IS_NOT";
    public static const CONTAINS:String = "CONTAINS";

    public static const YES:String = "YES";
    public static const NO:String = "NO";

}
}

/*
# Copyright (c) 2008-2010 rPath, Inc.
#
# This program is distributed under the terms of the MIT License as found
# in a file called LICENSE. If it is not present, the license
# is always available at http://www.opensource.org/licenses/mit-license.php.
#
# This program 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 MIT License for full details.
#
*/

package com.rpath.xobj
{
import flash.events.EventDispatcher;

[Bindable]
public class FilterTerm
{
    public function FilterTerm(name:String,
                               value:String,
                               operator:String = EQUAL)
    {
        super();

        this.name = name;
        this.operator = operator;
        this.value = value;
    }

    /**
     * The field/property to filter on (LHS)
     */
    public var name:String;

    /**
     * The logical operator to apply (see static consts below)
     */
    public var operator:String;

    /**
     * The value to test the field against (RHS)
     */
    public var value:String;

    public static const EQUAL:String = "EQUALS";
    public static const NOT_EQUAL:String = "NOT_EQUALS";
    public static const LESS_THAN:String = "LESS_THAN";
    public static const LESS_THAN_OR_EQUAL:String = "LESS_THAN_OR_EQUAL";
    public static const GREATER_THAN:String = "GREATER_THAN";
    public static const GREATER_THAN_OR_EQUAL:String = "GREATER_THAN_OR_EQUAL";
    public static const LIKE:String = "LIKE";
    public static const NOT_LIKE:String = "NOT_LIKE";
    public static const IN:String = "IN";
    public static const NOT_IN:String = "NOT_IN";
    public static const MATCHING:String = "MATCHING";
    public static const NOT_MATCHING:String = "NOT_MATCHING";

    public static const IS:String = "IS";
    public static const IS_NOT:String = "IS_NOT";
    public static const CONTAINS:String = "CONTAINS";

    public static const YES:String = "YES";
    public static const NO:String = "NO";

}
}

Make FilterTerm bindable

Make FilterTerm bindable


package com.kaltura.kdpfl.plugin.component
{
	import com.kaltura.kdpfl.model.ConfigProxy;
	import com.kaltura.kdpfl.model.ExternalInterfaceProxy;
	import com.kaltura.kdpfl.model.MediaProxy;
	import com.kaltura.kdpfl.model.SequenceProxy;
	import com.kaltura.kdpfl.model.type.NotificationType;
	import com.kaltura.kdpfl.view.media.KMediaPlayerMediator;
	import com.kaltura.vo.KalturaPlayableEntry;
	import com.omniture.AppMeasurement;

	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.external.ExternalInterface;

	import mx.utils.ObjectProxy;

	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.facade.Facade;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class OmnitureMediator extends Mediator
	{
		/**
		 * mediator name
		 */
		public static const NAME:String = "omnitureMediator";

		private var _ready:Boolean = false;
		private var _inSeek:Boolean = false;
		private var _inDrag:Boolean = false;
		private var _inFF:Boolean = false;
		private var _p25Once:Boolean = false;
		private var _p50Once:Boolean = false;
		private var _p75Once:Boolean = false;
		private var _p100Once:Boolean = false;
		private var _played:Boolean = false;
		private var _wasBuffering:Boolean = false;
		private var _hasSeeked:Boolean = false;
		private var _isReplay:Boolean = false;
		private var _mediaIsLoaded:Boolean=false;
		private var _fullScreen:Boolean=false;
		private var _normalScreen:Boolean=false;
		private var _lastSeek:Number=0;
		private var _playheadPosition:Number=0;
		private var _lastId : String = "";
		private var _isNewLoad : Boolean = false;
		public var _mediaName : String;

		private var _duration : Number;

		public var dynamicConfig:String;
		public var debugMode:String;

		public var charSet:String = "UTF-8";
		public var currencyCode:String = "USD";
		public var dc:String = "122";
		public var eventDispatcher : EventDispatcher = new EventDispatcher();

		public static const VIDEO_VIEW_EVENT:String = "videoViewEvent";
		public static const VIDEO_AUTOPLAY_EVENT:String = "videoAutoPlayEvent";
		public static const SHARE_EVENT:String = "shareEvent";
		public static const OPEN_FULL_SCREEN_EVENT:String = "openFullscreenEvent";
		public static const CLOSE_FULL_SCREEN_EVENT:String = "closefullscreenEvent";
		public static const SAVE_EVENT:String = "saveEvent";
		public static const REPLAY_EVENT:String = "replayEvent";
		public static const PERCENT_50:String = "percent50";
		public static const SEEK_EVENT:String = "seekEvent";
		public static const CHANGE_MEDIA_EVENT:String = "changeMediaEvent";
		public static const GOTO_CONTRIBUTOR_WINDOW_EVENT:String = "gotoContributorWindowEvent";
		public static const GOTO_EDITOR_WINDOW_EVENT:String = "gotoEditorWindowEvent";
		public static const PLAYER_PLAY_END_EVENT:String = "playerPlayEndEvent";
		public static const MEDIA_READY_EVENT:String = "mediaReadyEvent";
		public static const WATERMARK_CLICK:String = "watermarkClick";
		private	var eip:ExternalInterfaceProxy = Facade.getInstance().retrieveProxy("externalInterfaceProxy") as ExternalInterfaceProxy;

		private var _isReady:Boolean = false;
		private var _autoplayed:Boolean = false;

		/**
		 * disable statistics
		 */
		public var statsDis : Boolean;

		/**
		 * Omniture account
		 */
		public var account  :String;

		/**
		 * Omniture visitor namespace
		 */
		public var visitorNamespace  :String;

		/**
		 * Omniture tracking server
		 */
		public var trackingServer  :String;

		/**
		 * entry percents to track
		 */
		public var trackMilestones  :String;
		/**
		 * Custom general events
		 */
		public var customEvents:Array = new Array();

		public var s:AppMeasurement;
		private var cp:Object;

		/**
		 * Constructor.
		 */
		public function OmnitureMediator(customEvents:Array)
		{
			if (customEvents)
			{
				this.customEvents = customEvents;
			}
			super(NAME);
		}

		/**
		* External interface to extract the suit from the page
		*/
		private function getOmniVar(omnivar:String):String {

			//TODO - pass this through the ExternalInterfaceProxy once it will
			return ExternalInterface.call("function() { return "+omnivar+";}");
		}

		/**
		 * After all parameters are set - init the AppMeasurement object
		 */
		public function init():void
		{
			cp = Facade.getInstance().retrieveProxy("configProxy");
			var f:Object = Facade.getInstance();
			s = new AppMeasurement();
			//this feature allows to extract the configuration from the page
			if(dynamicConfig == "true")
			{
				eip.addCallback("omnitureKdpJsReady",omnitureKdpJsReady);
				return;
			}	else
			{
				if(visitorNamespace.indexOf("*")>-1)
					visitorNamespace.split("*").join(".");
				s.visitorNamespace = visitorNamespace;
				s.trackingServer = trackingServer;
				s.account = account;
				s.charSet = charSet;
				s.currencyCode = currencyCode;
			}
			prepareAppMeasurement();
		}
		public function omnitureKdpJsReady():void
		{
			s.visitorNamespace = getOmniVar("com.TI.Metrics.tcNameSpace");
			s.trackingServer = getOmniVar("com.TI.Metrics.tcTrackingServer");
			s.account = getOmniVar("com.TI.Metrics.tcReportSuiteID");
			s.charSet = getOmniVar("com.TI.Metrics.tcCharSet");
			s.currencyCode = getOmniVar("com.TI.Metrics.tcCurrencyCode");
			prepareAppMeasurement();
		}

		/**
		 * Prepare the AppMeasurement attributes and turn on the flag that sais that this is ready.
		 */
		private function prepareAppMeasurement():void
		{
			s.dc = dc;
			s.debugTracking = debugMode =="true" ? true : false ;
			s.trackLocal = true;
			s.Media.trackWhilePlaying = true;
			s.pageName = cp.vo.flashvars.referer;
			s.pageURL = cp.vo.flashvars.referer;
			s.Media.trackMilestones = trackMilestones;
			s.trackClickMap = true;
			if(cp.vo.kuiConf && cp.vo.kuiConf.name)
				s.Media.playerName= cp.vo.kuiConf.name;
			else
				s.Media.playerName= 'localPlayer';
			_isReady = true;
		}

		private function onAddedToStage(evt:Event):void
		{
			(viewComponent as DisplayObjectContainer).addChild(s);
		}

		/**
		 * Hook to the relevant KDP notifications
		 */
		override public function listNotificationInterests():Array
		{

			var notificationsArray:Array =  [
				NotificationType.HAS_OPENED_FULL_SCREEN,
				NotificationType.HAS_CLOSED_FULL_SCREEN,
				NotificationType.PLAYER_UPDATE_PLAYHEAD,
				NotificationType.PLAYER_READY,
				NotificationType.PLAYER_PLAYED,
				NotificationType.MEDIA_READY,
				NotificationType.DURATION_CHANGE,
				NotificationType.PLAYER_SEEK_START,
				NotificationType.PLAYER_SEEK_END,
				NotificationType.SCRUBBER_DRAG_START,
				NotificationType.SCRUBBER_DRAG_END,
				NotificationType.PLAYER_PAUSED,
				NotificationType.PLAYER_PLAY_END,
				NotificationType.CHANGE_MEDIA,
				"doGigya",
				"doDownload",
				"watermarkClick",
				NotificationType.DO_PLAY,
				NotificationType.DO_REPLAY,
				NotificationType.KDP_READY,
				NotificationType.DO_SEEK

											];

			notificationsArray = notificationsArray.concat(customEvents);
			return notificationsArray;
		}

		/**
		 * @inheritDocs
		 */
		override public function handleNotification(note:INotification):void
		{
			if (statsDis) return;
			//trace("in handle notification: ", note.getName());
			var kc: Object =  facade.retrieveProxy("servicesProxy")["kalturaClient"];
			var data:Object = note.getBody();
			var sequenceProxy : SequenceProxy = facade.retrieveProxy(SequenceProxy.NAME) as SequenceProxy;
			switch(note.getName())
			{
				case NotificationType.PLAYER_READY:
				//this is useless since the event happens before the OmniturePlugin is ready for use
				//TOCHECK - do we neeed this ? ANswer - not at the current!
				//sendGeneralNotification("widgetLoaded");
				break;

				case NotificationType.HAS_OPENED_FULL_SCREEN:
				 if(_fullScreen==false)
				 {
					sendGeneralNotification(OPEN_FULL_SCREEN_EVENT);
				 }
				_fullScreen=true;
				_normalScreen=false;
				break;
				case NotificationType.HAS_CLOSED_FULL_SCREEN:
				if(_normalScreen==false)
				{
					sendGeneralNotification(CLOSE_FULL_SCREEN_EVENT);
				}
				_fullScreen=false;
				_normalScreen=true;
				break;
				case "watermarkClick":
					sendGeneralNotification(WATERMARK_CLICK);
				break;
				case "playerPlayEnd":
					s.Media.close(cp.vo.kuiConf.name);
					sendGeneralNotification(PLAYER_PLAY_END_EVENT);
				break;
				case NotificationType.PLAYER_PLAYED:
					if (!sequenceProxy.vo.isInSequence && !_played )
					{

						s.Media.play(_mediaName,_playheadPosition);
						//seperate in case of autoplay:
						_played = true;
						if(cp.vo.flashvars.hasOwnProperty('autoPlay') && cp.vo.flashvars.autoPlay == "true" && !_autoplayed)
						{
							_autoplayed = true;
							sendGeneralNotification(VIDEO_AUTOPLAY_EVENT);
						} else
						sendGeneralNotification(VIDEO_VIEW_EVENT);
					}
				break;
				case "doDownload":
					sendGeneralNotification(SAVE_EVENT);
				break;
				case "doGigya":
					sendGeneralNotification(SHARE_EVENT);
				break;
				case NotificationType.MEDIA_READY:
					var bla:Object = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry;
				    if((facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id){
				    	if (_lastId != (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id)
				    	{
							_mediaName = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.name;

							var media:KalturaPlayableEntry = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry as KalturaPlayableEntry;
							if (media)
								_duration = media.duration;
				    		_played = false;
				    		_lastId = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id;
				    		_isNewLoad = true;
							sendGeneralNotification(MEDIA_READY_EVENT);
							_p50Once = false;
							_autoplayed = false;
				    	}
				    	else
				    	{
				    		_isNewLoad = false;
				    		_lastSeek = 0;
				    	}
				    	_mediaIsLoaded=true;
				    }
					s.movieID = _lastId;
					if(media)
					{
						s.Media.close(cp.vo.kuiConf.name);
						s.Media.open(_mediaName,media.duration, cp.vo.kuiConf.name);
					}

				break;

				case NotificationType.DURATION_CHANGE:
					if(_isNewLoad){
						_hasSeeked = false;
					}
					return;
				break;
				case NotificationType.PLAYER_SEEK_END:
					_inSeek = false;
					var kmpm:KMediaPlayerMediator = (facade.retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator);
					trace("sent ",kmpm.player.currentTime);
					s.Media.play(_mediaName,kmpm.player.currentTime);
					//to see if we are passed 50% or not
					return;
				break;

				case NotificationType.SCRUBBER_DRAG_START:
					_inDrag = true;
					return;
				break;

				case NotificationType.SCRUBBER_DRAG_END:
					_inDrag = false;
					_inSeek = false;
					return;
				break;

				case NotificationType.PLAYER_UPDATE_PLAYHEAD:
					_playheadPosition = data as Number;
					// add a 50% notification
					trace(_playheadPosition , (_duration/2))
					if(!_p50Once && _playheadPosition > (_duration/2))
					{
						_p50Once = true;
						sendGeneralNotification(PERCENT_50);
					}
				break;

				case NotificationType.KDP_READY:
				//Ready should not occur more than once
					if (_ready) return;
					_ready = true;
				break;
				case NotificationType.DO_SEEK:
					_lastSeek = Number(note.getBody());
					s.Media.stop(_mediaName,_playheadPosition);
					if(_inDrag && !_inSeek && !_isReplay)
					{
						sendGeneralNotification(SEEK_EVENT);
					}
					_inSeek = true;
					_hasSeeked = true;
					_isReplay = false;

				break;

				case NotificationType.DO_REPLAY:
					s.Media.open(_mediaName, _duration , cp.vo.kuiConf.name);
					sendGeneralNotification(REPLAY_EVENT); //TODO, fix the seek event being sent after replay. at the current this relies on the replay command happening before the seek
					_isReplay = true;
				break;
				/*case "doPlay":
					s.Media.play(_mediaName,_playheadPosition);
				break;*/
				case NotificationType.PLAYER_PAUSED:
					var currentTime : Number = (facade.retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator).player.currentTime;
					s.Media.stop(_mediaName,currentTime);
				break;

				default:
					//make sure we use the default only to the custom events
					for (var o:Object in customEvents)
					{
						if (note.getName() == customEvents[o].toString())
						{
							 sendGeneralNotification(note.getName())
							break;
						}
					}
				break;

			}
		}
		/**
		 * Send a general notification. let the code handle the logic
		 *
		 */
		private function sendGeneralNotification(evt:String):void
		{
			eventDispatcher.dispatchEvent(new Event(evt));
		}

		/**
		 * view component
		 */
		public function get view() : DisplayObject
		{
			return viewComponent as DisplayObject;
		}

		// unique

	}
}

package com.kaltura.kdpfl.plugin.component
{
	import com.kaltura.kdpfl.model.ConfigProxy;
	import com.kaltura.kdpfl.model.ExternalInterfaceProxy;
	import com.kaltura.kdpfl.model.MediaProxy;
	import com.kaltura.kdpfl.model.SequenceProxy;
	import com.kaltura.kdpfl.model.type.NotificationType;
	import com.kaltura.kdpfl.view.media.KMediaPlayerMediator;
	import com.kaltura.vo.KalturaPlayableEntry;
	import com.omniture.AppMeasurement;

	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.external.ExternalInterface;

	import mx.utils.ObjectProxy;

	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.facade.Facade;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class OmnitureMediator extends Mediator
	{
		/**
		 * mediator name
		 */
		public static const NAME:String = "omnitureMediator";

		private var _ready:Boolean = false;
		private var _inSeek:Boolean = false;
		private var _inDrag:Boolean = false;
		private var _inFF:Boolean = false;
		private var _p25Once:Boolean = false;
		private var _p50Once:Boolean = false;
		private var _p75Once:Boolean = false;
		private var _p100Once:Boolean = false;
		private var _played:Boolean = false;
		private var _wasBuffering:Boolean = false;
		private var _hasSeeked:Boolean = false;
		private var _isReplay:Boolean = false;
		private var _mediaIsLoaded:Boolean=false;
		private var _fullScreen:Boolean=false;
		private var _normalScreen:Boolean=false;
		private var _lastSeek:Number=0;
		private var _playheadPosition:Number=0;
		private var _lastId : String = "";
		private var _isNewLoad : Boolean = false;
		public var _mediaName : String;

		private var _duration : Number;

		public var dynamicConfig:String;
		public var debugMode:String;

		public var charSet:String = "UTF-8";
		public var currencyCode:String = "USD";
		public var dc:String = "122";
		public var eventDispatcher : EventDispatcher = new EventDispatcher();

		public static const VIDEO_VIEW_EVENT:String = "videoViewEvent";
		public static const VIDEO_AUTOPLAY_EVENT:String = "videoAutoPlayEvent";
		public static const SHARE_EVENT:String = "shareEvent";
		public static const OPEN_FULL_SCREEN_EVENT:String = "openFullscreenEvent";
		public static const CLOSE_FULL_SCREEN_EVENT:String = "closefullscreenEvent";
		public static const SAVE_EVENT:String = "saveEvent";
		public static const REPLAY_EVENT:String = "replayEvent";
		public static const PERCENT_50:String = "percent50";
		public static const SEEK_EVENT:String = "seekEvent";
		public static const CHANGE_MEDIA_EVENT:String = "changeMediaEvent";
		public static const GOTO_CONTRIBUTOR_WINDOW_EVENT:String = "gotoContributorWindowEvent";
		public static const GOTO_EDITOR_WINDOW_EVENT:String = "gotoEditorWindowEvent";
		public static const PLAYER_PLAY_END_EVENT:String = "playerPlayEndEvent";
		public static const MEDIA_READY_EVENT:String = "mediaReadyEvent";
		public static const WATERMARK_CLICK:String = "watermarkClick";
		private	var eip:ExternalInterfaceProxy = Facade.getInstance().retrieveProxy("externalInterfaceProxy") as ExternalInterfaceProxy;

		private var _isReady:Boolean = false;
		private var _autoplayed:Boolean = false;

		/**
		 * disable statistics
		 */
		public var statsDis : Boolean;

		/**
		 * Omniture account
		 */
		public var account  :String;

		/**
		 * Omniture visitor namespace
		 */
		public var visitorNamespace  :String;

		/**
		 * Omniture tracking server
		 */
		public var trackingServer  :String;

		/**
		 * entry percents to track
		 */
		public var trackMilestones  :String;
		/**
		 * Custom general events
		 */
		public var customEvents:Array = new Array();

		public var s:AppMeasurement;
		private var cp:Object;

		/**
		 * Constructor.
		 */
		public function OmnitureMediator(customEvents:Array)
		{
			if (customEvents)
			{
				this.customEvents = customEvents;
			}
			super(NAME);
		}

		/**
		* External interface to extract the suit from the page
		*/
		private function getOmniVar(omnivar:String):String {

			//TODO - pass this through the ExternalInterfaceProxy once it will
			return ExternalInterface.call("function() { return "+omnivar+";}");
		}

		/**
		 * After all parameters are set - init the AppMeasurement object
		 */
		public function init():void
		{
			cp = Facade.getInstance().retrieveProxy("configProxy");
			var f:Object = Facade.getInstance();
			s = new AppMeasurement();
			//this feature allows to extract the configuration from the page
			if(dynamicConfig == "true")
			{
				eip.addCallback("omnitureKdpJsReady",omnitureKdpJsReady);
				return;
			}	else
			{
				if(visitorNamespace.indexOf("*")>-1)
					visitorNamespace.split("*").join(".");
				s.visitorNamespace = visitorNamespace;
				s.trackingServer = trackingServer;
				s.account = account;
				s.charSet = charSet;
				s.currencyCode = currencyCode;
			}
			prepareAppMeasurement();
		}
		public function omnitureKdpJsReady():void
		{
			s.visitorNamespace = getOmniVar("com.TI.Metrics.tcNameSpace");
			s.trackingServer = getOmniVar("com.TI.Metrics.tcTrackingServer");
			s.account = getOmniVar("com.TI.Metrics.tcReportSuiteID");
			s.charSet = getOmniVar("com.TI.Metrics.tcCharSet");
			s.currencyCode = getOmniVar("com.TI.Metrics.tcCurrencyCode");
			prepareAppMeasurement();
		}

		/**
		 * Prepare the AppMeasurement attributes and turn on the flag that sais that this is ready.
		 */
		private function prepareAppMeasurement():void
		{
			s.dc = dc;
			s.debugTracking = debugMode =="true" ? true : false ;
			s.trackLocal = true;
			s.Media.trackWhilePlaying = true;
			s.pageName = cp.vo.flashvars.referer;
			s.pageURL = cp.vo.flashvars.referer;
			s.Media.trackMilestones = trackMilestones;
			s.trackClickMap = true;
			if(cp.vo.kuiConf && cp.vo.kuiConf.name)
				s.Media.playerName= cp.vo.kuiConf.name;
			else
				s.Media.playerName= 'localPlayer';
			_isReady = true;
		}

		private function onAddedToStage(evt:Event):void
		{
			(viewComponent as DisplayObjectContainer).addChild(s);
		}

		/**
		 * Hook to the relevant KDP notifications
		 */
		override public function listNotificationInterests():Array
		{

			var notificationsArray:Array =  [
				NotificationType.HAS_OPENED_FULL_SCREEN,
				NotificationType.HAS_CLOSED_FULL_SCREEN,
				NotificationType.PLAYER_UPDATE_PLAYHEAD,
				NotificationType.PLAYER_READY,
				NotificationType.PLAYER_PLAYED,
				NotificationType.MEDIA_READY,
				NotificationType.DURATION_CHANGE,
				NotificationType.PLAYER_SEEK_START,
				NotificationType.PLAYER_SEEK_END,
				NotificationType.SCRUBBER_DRAG_START,
				NotificationType.SCRUBBER_DRAG_END,
				NotificationType.PLAYER_PAUSED,
				NotificationType.PLAYER_PLAY_END,
				NotificationType.CHANGE_MEDIA,
				"doGigya",
				"showAdvancedShare",
				"doDownload",
				"watermarkClick",
				NotificationType.DO_PLAY,
				NotificationType.DO_REPLAY,
				NotificationType.KDP_READY,
				NotificationType.DO_SEEK

											];

			notificationsArray = notificationsArray.concat(customEvents);
			return notificationsArray;
		}

		/**
		 * @inheritDocs
		 */
		override public function handleNotification(note:INotification):void
		{
			if (statsDis) return;
			//trace("in handle notification: ", note.getName());
			var kc: Object =  facade.retrieveProxy("servicesProxy")["kalturaClient"];
			var data:Object = note.getBody();
			var sequenceProxy : SequenceProxy = facade.retrieveProxy(SequenceProxy.NAME) as SequenceProxy;
			switch(note.getName())
			{
				case NotificationType.PLAYER_READY:
				//this is useless since the event happens before the OmniturePlugin is ready for use
				//TOCHECK - do we neeed this ? ANswer - not at the current!
				//sendGeneralNotification("widgetLoaded");
				break;

				case NotificationType.HAS_OPENED_FULL_SCREEN:
				 if(_fullScreen==false)
				 {
					sendGeneralNotification(OPEN_FULL_SCREEN_EVENT);
				 }
				_fullScreen=true;
				_normalScreen=false;
				break;
				case NotificationType.HAS_CLOSED_FULL_SCREEN:
				if(_normalScreen==false)
				{
					sendGeneralNotification(CLOSE_FULL_SCREEN_EVENT);
				}
				_fullScreen=false;
				_normalScreen=true;
				break;
				case "watermarkClick":
					sendGeneralNotification(WATERMARK_CLICK);
				break;
				case "playerPlayEnd":
					s.Media.close(cp.vo.kuiConf.name);
					sendGeneralNotification(PLAYER_PLAY_END_EVENT);
				break;
				case NotificationType.PLAYER_PLAYED:
					if (!sequenceProxy.vo.isInSequence && !_played )
					{

						s.Media.play(_mediaName,_playheadPosition);
						//seperate in case of autoplay:
						_played = true;
						if(cp.vo.flashvars.hasOwnProperty('autoPlay') && cp.vo.flashvars.autoPlay == "true" && !_autoplayed)
						{
							_autoplayed = true;
							sendGeneralNotification(VIDEO_AUTOPLAY_EVENT);
						} else
						sendGeneralNotification(VIDEO_VIEW_EVENT);
					}
				break;
				case "doDownload":
					sendGeneralNotification(SAVE_EVENT);
				break;
				case "doGigya":
				case "showAdvancedShare":
					sendGeneralNotification(SHARE_EVENT);
				break;
				case NotificationType.MEDIA_READY:
					var bla:Object = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry;
				    if((facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id){
				    	if (_lastId != (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id)
				    	{
							_mediaName = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.name;

							var media:KalturaPlayableEntry = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry as KalturaPlayableEntry;
							if (media)
								_duration = media.duration;
				    		_played = false;
				    		_lastId = (facade.retrieveProxy(MediaProxy.NAME) as MediaProxy).vo.entry.id;
				    		_isNewLoad = true;
							sendGeneralNotification(MEDIA_READY_EVENT);
							_p50Once = false;
							_autoplayed = false;
				    	}
				    	else
				    	{
				    		_isNewLoad = false;
				    		_lastSeek = 0;
				    	}
				    	_mediaIsLoaded=true;
				    }
					s.movieID = _lastId;
					if(media)
					{
						s.Media.close(cp.vo.kuiConf.name);
						s.Media.open(_mediaName,media.duration, cp.vo.kuiConf.name);
					}

				break;

				case NotificationType.DURATION_CHANGE:
					if(_isNewLoad){
						_hasSeeked = false;
					}
					return;
				break;
				case NotificationType.PLAYER_SEEK_END:
					_inSeek = false;
					var kmpm:KMediaPlayerMediator = (facade.retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator);
					trace("sent ",kmpm.player.currentTime);
					s.Media.play(_mediaName,kmpm.player.currentTime);
					//to see if we are passed 50% or not
					return;
				break;

				case NotificationType.SCRUBBER_DRAG_START:
					_inDrag = true;
					return;
				break;

				case NotificationType.SCRUBBER_DRAG_END:
					_inDrag = false;
					_inSeek = false;
					return;
				break;

				case NotificationType.PLAYER_UPDATE_PLAYHEAD:
					_playheadPosition = data as Number;
					// add a 50% notification
					trace(_playheadPosition , (_duration/2))
					if(!_p50Once && _playheadPosition > (_duration/2))
					{
						_p50Once = true;
						sendGeneralNotification(PERCENT_50);
					}
				break;

				case NotificationType.KDP_READY:
				//Ready should not occur more than once
					if (_ready) return;
					_ready = true;
				break;
				case NotificationType.DO_SEEK:
					_lastSeek = Number(note.getBody());
					s.Media.stop(_mediaName,_playheadPosition);
					if(_inDrag && !_inSeek && !_isReplay)
					{
						sendGeneralNotification(SEEK_EVENT);
					}
					_inSeek = true;
					_hasSeeked = true;
					_isReplay = false;

				break;

				case NotificationType.DO_REPLAY:
					s.Media.open(_mediaName, _duration , cp.vo.kuiConf.name);
					sendGeneralNotification(REPLAY_EVENT); //TODO, fix the seek event being sent after replay. at the current this relies on the replay command happening before the seek
					_isReplay = true;
				break;
				/*case "doPlay":
					s.Media.play(_mediaName,_playheadPosition);
				break;*/
				case NotificationType.PLAYER_PAUSED:
					var currentTime : Number = (facade.retrieveMediator(KMediaPlayerMediator.NAME) as KMediaPlayerMediator).player.currentTime;
					s.Media.stop(_mediaName,currentTime);
				break;

				default:
					//make sure we use the default only to the custom events
					for (var o:Object in customEvents)
					{
						if (note.getName() == customEvents[o].toString())
						{
							 sendGeneralNotification(note.getName())
							break;
						}
					}
				break;

			}
		}
		/**
		 * Send a general notification. let the code handle the logic
		 *
		 */
		private function sendGeneralNotification(evt:String):void
		{
			eventDispatcher.dispatchEvent(new Event(evt));
		}

		/**
		 * view component
		 */
		public function get view() : DisplayObject
		{
			return viewComponent as DisplayObject;
		}

		// unique

	}
}

add "showAdvancedShare" event

qnd: add "showAdvancedShare" event

git-svn-id: 3f608e5a9a704dd448217c0a64c508e7f145cfa1@86972 6b8eccd3-e8c5-4e7d-8186-e12b5326b719


package aerys.minko.scene.controller.mesh
{
	import aerys.minko.render.Viewport;
	import aerys.minko.render.resource.texture.TextureResource;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.binding.DataProvider;

	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	/**
	 * The DynamicTextureController makes it possible to use Flash DisplayObjects
	 * as dynamic textures.
	 *
	 * <p>
	 * The DynamicTextureController listen for the Scene.enterFrame signal and
	 * update the specified texture property of the targeted Meshes by rasterizing
	 * the source Flash DisplayObject.
	 * </p>
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class DynamicTextureController extends EnterFrameController
	{
		private var _data					: DataProvider;

		private var _source					: DisplayObject;
		private var _framerate				: Number;
		private var _mipMapping				: Boolean;
		private var _propertyName			: String;
		private var _matrix					: Matrix;
		private var _forceBitmapDataClear	: Boolean;
		private var _bitmapData				: BitmapData;
		private var _texture				: TextureResource;

		private var _lastDraw	            : Number;

		/**
		 * Create a new DynamicTextureController.
		 *
		 * @param source The source DisplayObject to use as a dynamic texture.
		 * @param width The width of the dynamic texture.
		 * @param height The height of the dynamic texture.
		 * @param mipMapping Whether mip-mapping should be enabled or not. Default value is 'true'.
		 * @param framerate The frame rate of the dynamic texture. Default value is '30'.
		 * @param propertyName The name of the bindings property that should be set with the
		 * dynamic texture. Default value if 'diffuseMap'.
		 * @param matrix The Matrix object that shall be used when rasterizing the DisplayObject
		 * into the dynamic texture. Default value is 'null'.
		 *
		 */
		public function DynamicTextureController(source					: DisplayObject,
												 width					: Number,
												 height					: Number,
												 mipMapping				: Boolean	= true,
												 framerate				: Number	= 30.,
												 propertyName			: String	= 'diffuseMap',
												 matrix					: Matrix	= null,
												 forceBitmapDataClear	: Boolean	= false)
		{
			super();

			_source = source;
			_texture = new TextureResource(width, height);
			_framerate = framerate;
			_mipMapping = mipMapping;
			_propertyName = propertyName;
			_matrix = matrix;
			_forceBitmapDataClear = forceBitmapDataClear;

			_data = new DataProvider();
			_data.setProperty(propertyName, _texture);
		}

		public function get forceBitmapDataClear():Boolean
		{
			return _forceBitmapDataClear;
		}

		public function set forceBitmapDataClear(value:Boolean):void
		{
			_forceBitmapDataClear = value;
		}

		override protected function targetAddedHandler(ctrl		: EnterFrameController,
													   target	: ISceneNode) : void
		{
			super.targetAddedHandler(ctrl, target);

//			(target as Mesh).properties.setProperty(_propertyName, _texture);
			if (target is Scene)
				(target as Scene).bindings.addProvider(_data);
			else if (target is Mesh)
				(target as Mesh).bindings.addProvider(_data);
			else
				throw new Error();
		}

		override protected function targetRemovedHandler(ctrl	: EnterFrameController,
														 target	: ISceneNode) : void
		{
			super.targetRemovedHandler(ctrl, target);

//			(target as Mesh).properties.removeProperty(_propertyName);

			if (target is Scene)
				(target as Scene).bindings.removeProvider(_data);
			else if (target is Mesh)
				(target as Mesh).bindings.removeProvider(_data);
		}

		override protected function sceneEnterFrameHandler(scene	: Scene,
														   viewport	: Viewport,
														   target	: BitmapData,
														   time		: Number) : void
		{
			if (time - _lastDraw > 1000. / _framerate)
			{
				_lastDraw = time;

				_bitmapData ||= new BitmapData(_source.width, _source.height);
				if (_forceBitmapDataClear)
				{
					_bitmapData.fillRect(new Rectangle(0, 0, _bitmapData.width, _bitmapData.height), 0);
				}
				_bitmapData.draw(_source, _matrix);

				_texture.setContentFromBitmapData(_bitmapData, _mipMapping);
			}
		}
	}
}

package aerys.minko.scene.controller.mesh
{
	import aerys.minko.render.Viewport;
	import aerys.minko.render.resource.texture.TextureResource;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.binding.DataProvider;

	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	/**
	 * The DynamicTextureController makes it possible to use Flash DisplayObjects
	 * as dynamic textures.
	 *
	 * <p>
	 * The DynamicTextureController listen for the Scene.enterFrame signal and
	 * update the specified texture property of the targeted Meshes by rasterizing
	 * the source Flash DisplayObject.
	 * </p>
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class DynamicTextureController extends EnterFrameController
	{
		private var _data					: DataProvider;

		private var _source					: DisplayObject;
		private var _framerate				: Number;
		private var _mipMapping				: Boolean;
		private var _propertyName			: String;
		private var _matrix					: Matrix;
		private var _forceBitmapDataClear	: Boolean;
		private var _bitmapData				: BitmapData;
		private var _texture				: TextureResource;

		private var _lastDraw	            : Number;

		/**
		 * Create a new DynamicTextureController.
		 *
		 * @param source The source DisplayObject to use as a dynamic texture.
		 * @param width The width of the dynamic texture.
		 * @param height The height of the dynamic texture.
		 * @param mipMapping Whether mip-mapping should be enabled or not. Default value is 'true'.
		 * @param framerate The frame rate of the dynamic texture. Default value is '30'.
		 * @param propertyName The name of the bindings property that should be set with the
		 * dynamic texture. Default value if 'diffuseMap'.
		 * @param matrix The Matrix object that shall be used when rasterizing the DisplayObject
		 * into the dynamic texture. Default value is 'null'.
		 *
		 */
		public function DynamicTextureController(source					: DisplayObject,
												 width					: Number,
												 height					: Number,
												 mipMapping				: Boolean	= true,
												 framerate				: Number	= 30.,
												 propertyName			: String	= 'diffuseMap',
												 matrix					: Matrix	= null,
												 forceBitmapDataClear	: Boolean	= false)
		{
			super();

			_source = source;
			_texture = new TextureResource(width, height);
			_framerate = framerate;
			_mipMapping = mipMapping;
			_propertyName = propertyName;
			_matrix = matrix;
			_forceBitmapDataClear = forceBitmapDataClear;

			_data = new DataProvider();
			_data.setProperty(propertyName, _texture);
		}

		public function get forceBitmapDataClear():Boolean
		{
			return _forceBitmapDataClear;
		}

		public function set forceBitmapDataClear(value:Boolean):void
		{
			_forceBitmapDataClear = value;
		}

		override protected function targetAddedHandler(ctrl		: EnterFrameController,
													   target	: ISceneNode) : void
		{
			super.targetAddedHandler(ctrl, target);

			if (target is Scene)
				(target as Scene).bindings.addProvider(_data);
			else if (target is Mesh)
				(target as Mesh).bindings.addProvider(_data);
			else
				throw new Error();
		}

		override protected function targetRemovedHandler(ctrl	: EnterFrameController,
														 target	: ISceneNode) : void
		{
			super.targetRemovedHandler(ctrl, target);

			if (target is Scene)
				(target as Scene).bindings.removeProvider(_data);
			else if (target is Mesh)
				(target as Mesh).bindings.removeProvider(_data);
		}

		override protected function sceneEnterFrameHandler(scene	: Scene,
														   viewport	: Viewport,
														   target	: BitmapData,
														   time		: Number) : void
		{
			if (!_lastDraw || time - _lastDraw > 1000. / _framerate)
			{
				_lastDraw = time;

				_bitmapData ||= new BitmapData(_source.width, _source.height);
				if (_forceBitmapDataClear)
					_bitmapData.fillRect(
                        new Rectangle(0, 0, _bitmapData.width, _bitmapData.height),
                        0
                    );

				_bitmapData.draw(_source, _matrix);

				_texture.setContentFromBitmapData(_bitmapData, _mipMapping);
			}
		}
	}
}

fix DynamicTextureController.sceneEnterFrameHandler() to make sure the source is rasterized/uploaded to init. the texture and avoid error 3700 at the first frame


package org.mangui.jwplayer.media {
    import org.mangui.HLS.parsing.Level;
    import org.mangui.HLS.*;
    import org.mangui.HLS.utils.Log;
    import org.mangui.HLS.utils.ScaleVideo;

    import com.longtailvideo.jwplayer.events.MediaEvent;
    import com.longtailvideo.jwplayer.model.PlayerConfig;
    import com.longtailvideo.jwplayer.model.PlaylistItem;
    import com.longtailvideo.jwplayer.media.*;
    import com.longtailvideo.jwplayer.player.PlayerState;
    import com.longtailvideo.jwplayer.utils.RootReference;

    import flash.display.DisplayObject;
    import flash.geom.Rectangle;
    import flash.media.SoundTransform;
    import flash.media.Video;
    import flash.media.StageVideo;
    import flash.system.Capabilities;
    import flash.events.Event;

    /** JW Player provider for hls streaming. **/
    public class HLSProvider extends MediaProvider {
        /** Reference to the framework. **/
        protected var _hls : HLS;
        /** Current quality level. **/
        protected var _level : Number;
        /** Reference to the quality levels. **/
        protected var _levels : Vector.<Level>;
        /** Reference to the video object. **/
        private var _video : Video;
        /** Reference to the stage video element. **/
        private var _stageVideo : StageVideo;
        /** Whether or not StageVideo is enabled (not working with JW5) **/
        protected var _stageEnabled : Boolean = false;
        /** current position **/
        protected var _media_position : Number;
        /** Video Original size **/
        private var _videoWidth : Number = 0;
        private var _videoHeight : Number = 0;
        private var _seekInLiveDurationThreshold : Number = 60;

        public function HLSProvider() {
            super('hls');
        };

        /** Forward completes from the framework. **/
        private function _completeHandler(event : HLSEvent) : void {
            complete();
        };

        /** Forward playback errors from the framework. **/
        private function _errorHandler(event : HLSEvent) : void {
            super.error(event.error.msg);
        };

        /** Forward QOS metrics on fragment load. **/
        protected function _fragmentHandler(event : HLSEvent) : void {
            _level = event.metrics.level;
            sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata:{bandwidth:Math.round(event.metrics.bandwidth / 1024), droppedFrames:_hls.stream.info.droppedFrames, currentLevel:(_level + 1) + ' of ' + _levels.length + ' (' + Math.round(_levels[_level].bitrate / 1024) + 'kbps, ' + _levels[_level].width + 'px)', width:_videoWidth}});
        };

        /** Update video A/R on manifest load. **/
        private function _manifestHandler(event : HLSEvent) : void {
            _levels = event.levels;
            // only report position/duration/buffer for VOD playlist and live playlist with duration > _seekInLiveDurationThreshold
            if (_hls.type == HLSTypes.VOD || _levels[0].duration > _seekInLiveDurationThreshold) {
                item.duration = _levels[0].duration;
            } else {
                item.duration = -1;
            }
            sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {position:0, duration:item.duration});
            _hls.addEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            /* start playback on manifest load */
            if (item.start != 0) {
                _hls.stream.seek(item.start);
            } else {
                _hls.stream.play();
            }
        };

        /** Update playback position. **/
        private function _mediaTimeHandler(event : HLSEvent) : void {
            // only report position/duration/buffer for VOD playlist and live playlist with duration > _seekInLiveDurationThreshold
            if (_hls.type == HLSTypes.VOD || event.mediatime.duration > _seekInLiveDurationThreshold) {
                item.duration = event.mediatime.duration;
                _media_position = Math.max(0, event.mediatime.position);
                var _bufferPercent : Number = 100 * (_media_position + event.mediatime.buffer) / event.mediatime.duration;
                sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {bufferPercent:_bufferPercent, offset:0, position:_media_position, duration:event.mediatime.duration});
            }
            var videoWidth : Number;
            var videoHeight : Number;
            if (_stageVideo) {
                videoWidth = _stageVideo.videoWidth;
                videoHeight = _stageVideo.videoHeight;
            } else {
                videoWidth = _video.videoWidth;
                videoHeight = _video.videoHeight;
            }

            if (videoWidth && videoHeight) {
                if (_videoWidth != videoWidth || _videoHeight != videoHeight) {
                    _videoHeight = videoHeight;
                    _videoWidth = videoWidth;
                    Log.info("video size changed to " + _videoWidth + "/" + _videoHeight);
                    // force resize to adjust video A/R
                    resize(videoWidth, _videoHeight);
                }
            }
        };

        /** Forward state changes from the framework. **/
        private function _stateHandler(event : HLSEvent) : void {
            switch(event.state) {
                case HLSPlayStates.IDLE:
                    setState(PlayerState.IDLE);
                    break;
                case HLSPlayStates.PLAYING_BUFFERING:
                case HLSPlayStates.PAUSED_BUFFERING:
                    setState(PlayerState.BUFFERING);
                    break;
                case HLSPlayStates.PLAYING:
                    _video.visible = true;
                    setState(PlayerState.PLAYING);
                    break;
                case HLSPlayStates.PAUSED:
                    setState(PlayerState.PAUSED);
                    break;
            }
        };

        private function _audioHandler(e : Event) : void {
            media = null;
            // sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED);
            // dispatchEvent(new MediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED));
        }

        /** Set the volume on init. **/
        override public function initializeMediaProvider(cfg : PlayerConfig) : void {
            super.initializeMediaProvider(cfg);
            _hls = new HLS();
            _hls.stage = RootReference.stage;
            _hls.stream.soundTransform = new SoundTransform(cfg.volume / 100);
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _completeHandler);
            _hls.addEventListener(HLSEvent.ERROR, _errorHandler);
            _hls.addEventListener(HLSEvent.FRAGMENT_LOADED, _fragmentHandler);
            _hls.addEventListener(HLSEvent.MANIFEST_LOADED, _manifestHandler);
            _hls.addEventListener(HLSEvent.PLAYBACK_STATE, _stateHandler);
            _hls.addEventListener(HLSEvent.AUDIO_ONLY, _audioHandler);

            // Allow stagevideo to be disabled by user config
            if (cfg.hasOwnProperty('stagevideo') && cfg['stagevideo'].toString() == "false") {
                _stageEnabled = false;
            }
            _video = new Video(320, 240);
            _video.smoothing = true;
            // Use stageVideo when available
            if (_stageEnabled && RootReference.stage.stageVideos.length > 0) {
                _stageVideo = RootReference.stage.stageVideos[0];
                _stageVideo.viewPort = new Rectangle(0, 0, 320, 240);
                _stageVideo.attachNetStream(_hls.stream);
                Log.info("stage video enabled");
            } else {
                _video.attachNetStream(_hls.stream);
            }

            _level = 0;
            var value : Object;

            // parse configuration parameters
            value = cfg.hls_debug;
            if (value != null) {
                Log.info("hls_debug:" + value);
                Log.LOG_DEBUG_ENABLED = value as Boolean;
            }

            value = cfg.hls_debug2;
            if (value != null) {
                Log.info("hls_debug2:" + value);
                Log.LOG_DEBUG2_ENABLED = value as Boolean;
            }

            value = cfg.hls_minbufferlength;
            if (value != null) {
                Log.info("hls_minbufferlength:" + value);
                _hls.minBufferLength = value as Number;
            }

            value = cfg.hls_maxbufferlength;
            if (value != null) {
                Log.info("hls_maxbufferlength:" + value);
                _hls.maxBufferLength = value as Number;
            }

            value = cfg.hls_lowbufferlength;
            if (value != null) {
                Log.info("hls_lowbufferlength:" + value);
                _hls.lowBufferLength = value as Number;
            }

            value = cfg.hls_startfromlowestlevel;
            if (value != null) {
                Log.info("hls_startfromlowestlevel:" + value);
                _hls.startFromLowestLevel = value as Boolean;
            }

            value = cfg.hls_seekfromlowestlevel;
            if (value != null) {
                Log.info("hls_seekfromlowestlevel:" + value);
                _hls.seekFromLowestLevel = value as Boolean;
            }

            value = cfg.hls_live_flushurlcache;
            if (value != null) {
                Log.info("hls_live_flushurlcache:" + value);
                _hls.flushLiveURLCache = value as Boolean;
            }

            value = cfg.hls_live_seekdurationthreshold;
            if (value != null) {
                Log.info("hls_live_seekdurationthreshold:" + value);
                _seekInLiveDurationThreshold = value as Number;
            }

            value = cfg.hls_seekmode;
            if (value != null) {
                Log.info("hls_seekmode:" + value);
                _hls.seekMode = value as String;
            }
            value = cfg.hls_fragmentloadmaxretry;
            if (value != null) {
                Log.info("hls_fragmentloadmaxretry:" + value);
                _hls.fragmentLoadMaxRetry = value as Number;
            }

            value = cfg.hls_manifestloadmaxretry;
            if (value != null) {
                Log.info("hls_manifestloadmaxretry:" + value);
                _hls.manifestLoadMaxRetry = value as Number;
            }

            value = cfg.hls_capleveltostage;
            if (value != null) {
                Log.info("hls_capleveltostage:" + value);
                if (value as Boolean == true) {
                    _hls.capLeveltoStage = true;
                }
            }
            mute(cfg.mute);
        };

        /** Check that Flash Player version is sufficient (10.1 or above) **/
        private function _checkVersion() : Number {
            var versionStr : String = Capabilities.version;
            var verArray : Array = versionStr.split(/\s|,/);
            var versionNum : Number = Number(String(verArray[1] + "." + verArray[2]));
            return versionNum;
        }

        /** Load a new playlist item **/
        override public function load(itm : PlaylistItem) : void {
            // Check flash player version
            var ver : Number = _checkVersion();
            var minVersion : Number = 11.6;
            if ( ver < minVersion ) {
                sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message:"This application requires Flash Player 11.6 at mimimum"});
            } else {
                super.load(itm);
                play();
            }
        };

        /** Get the video object. **/
        override public function get display() : DisplayObject {
            return _video;
        };

		public override function getRawMedia():DisplayObject
		{
			return display;

		}

        /** Resume playback of a paused item. **/
        override public function play() : void {
            if (state == PlayerState.PAUSED) {
                _hls.stream.resume();
            } else {
                setState(PlayerState.BUFFERING);
                _hls.load(item.file);
            }
        };

        /** Pause a playing item. **/
        override public function pause() : void {
            _hls.stream.pause();
        };

        /** Do a resize on the video. **/
        override public function resize(width : Number, height : Number) : void {
            Log.info("resize video from [" + _videoWidth + "," + _videoHeight + "]" + "to [" + width + "," + height + "]");
            _width = width;
            _height = height;
            if (_videoWidth && _videoHeight) {
                var rect : Rectangle = ScaleVideo.resizeRectangle(_videoWidth, _videoHeight, width, height);
                if (_stageVideo) {
                    _stageVideo.viewPort = rect;
                } else {
                    _video.x = rect.x;
                    _video.y = rect.y;
                    _video.width = rect.width;
                    _video.height = rect.height;
                }
            }
        };

        /** Seek to a certain position in the item. **/
        override public function seek(pos : Number) : void {
            _hls.stream.seek(pos);
        };

        /** Change the playback volume of the item. **/
        override public function setVolume(vol : Number) : void {
            _hls.stream.soundTransform = new SoundTransform(vol / 100);
            super.setVolume(vol);
        };

        /** Stop playback. **/
        override public function stop() : void {
            _hls.stream.close();
            super.stop();
            _hls.removeEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            _level = 0;
        };
    }
}

package org.mangui.jwplayer.media {
    import org.mangui.HLS.parsing.Level;
    import org.mangui.HLS.*;
    import org.mangui.HLS.utils.Log;
    import org.mangui.HLS.utils.ScaleVideo;

    import com.longtailvideo.jwplayer.events.MediaEvent;
    import com.longtailvideo.jwplayer.model.PlayerConfig;
    import com.longtailvideo.jwplayer.model.PlaylistItem;
    import com.longtailvideo.jwplayer.media.*;
    import com.longtailvideo.jwplayer.player.PlayerState;
    import com.longtailvideo.jwplayer.utils.RootReference;

    import flash.display.DisplayObject;
    import flash.geom.Rectangle;
    import flash.media.SoundTransform;
    import flash.media.Video;
    import flash.media.StageVideo;
    import flash.system.Capabilities;
    import flash.events.Event;

    /** JW Player provider for hls streaming. **/
    public class HLSProvider extends MediaProvider {
        /** Reference to the framework. **/
        protected var _hls : HLS;
        /** Current quality level. **/
        protected var _level : Number;
        /** Reference to the quality levels. **/
        protected var _levels : Vector.<Level>;
        /** Reference to the video object. **/
        private var _video : Video;
        /** Reference to the stage video element. **/
        private var _stageVideo : StageVideo;
        /** Whether or not StageVideo is enabled (not working with JW5) **/
        protected var _stageEnabled : Boolean = false;
        /** current position **/
        protected var _media_position : Number;
        /** Video Original size **/
        private var _videoWidth : Number = 0;
        private var _videoHeight : Number = 0;
        private var _seekInLiveDurationThreshold : Number = 60;

        public function HLSProvider() {
            super('hls');
        };

        /** Forward completes from the framework. **/
        private function _completeHandler(event : HLSEvent) : void {
            complete();
        };

        /** Forward playback errors from the framework. **/
        private function _errorHandler(event : HLSEvent) : void {
            super.error(event.error.msg);
        };

        /** Forward QOS metrics on fragment load. **/
        protected function _fragmentHandler(event : HLSEvent) : void {
            _level = event.metrics.level;
            sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_META, {metadata:{bandwidth:Math.round(event.metrics.bandwidth / 1024), droppedFrames:_hls.stream.info.droppedFrames, currentLevel:(_level + 1) + ' of ' + _levels.length + ' (' + Math.round(_levels[_level].bitrate / 1024) + 'kbps, ' + _levels[_level].width + 'px)', width:_videoWidth}});
        };

        /** Update video A/R on manifest load. **/
        private function _manifestHandler(event : HLSEvent) : void {
            _levels = event.levels;
            // only report position/duration/buffer for VOD playlist and live playlist with duration > _seekInLiveDurationThreshold
            if (_hls.type == HLSTypes.VOD || _levels[0].duration > _seekInLiveDurationThreshold) {
                item.duration = _levels[0].duration;
            } else {
                item.duration = -1;
            }
            sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {position:0, duration:item.duration});
            _hls.addEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            /* start playback on manifest load */
            if (item.start != 0) {
                _hls.stream.seek(item.start);
            } else {
                _hls.stream.play();
            }
        };

        /** Update playback position. **/
        private function _mediaTimeHandler(event : HLSEvent) : void {
            // only report position/duration/buffer for VOD playlist and live playlist with duration > _seekInLiveDurationThreshold
            if (_hls.type == HLSTypes.VOD || event.mediatime.duration > _seekInLiveDurationThreshold) {
                item.duration = event.mediatime.duration;
                _media_position = Math.max(0, event.mediatime.position);
                var _bufferPercent : Number = 100 * (_media_position + event.mediatime.buffer) / event.mediatime.duration;
                sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_TIME, {bufferPercent:_bufferPercent, offset:0, position:_media_position, duration:event.mediatime.duration});
            }
            var videoWidth : Number;
            var videoHeight : Number;
            if (_stageVideo) {
                videoWidth = _stageVideo.videoWidth;
                videoHeight = _stageVideo.videoHeight;
            } else {
                videoWidth = _video.videoWidth;
                videoHeight = _video.videoHeight;
            }

            if (videoWidth && videoHeight) {
                if (_videoWidth != videoWidth || _videoHeight != videoHeight) {
                    _videoHeight = videoHeight;
                    _videoWidth = videoWidth;
                    Log.info("video size changed to " + _videoWidth + "/" + _videoHeight);
                    // force resize to adjust video A/R
                    resize(videoWidth, _videoHeight);
                }
            }
        };

        /** Forward state changes from the framework. **/
        private function _stateHandler(event : HLSEvent) : void {
            switch(event.state) {
                case HLSPlayStates.IDLE:
                    setState(PlayerState.IDLE);
                    break;
                case HLSPlayStates.PLAYING_BUFFERING:
                case HLSPlayStates.PAUSED_BUFFERING:
                    setState(PlayerState.BUFFERING);
                    break;
                case HLSPlayStates.PLAYING:
                    _video.visible = true;
                    setState(PlayerState.PLAYING);
                    break;
                case HLSPlayStates.PAUSED:
                    setState(PlayerState.PAUSED);
                    break;
            }
        };

        private function _audioHandler(e : Event) : void {
            media = null;
            // sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED);
            // dispatchEvent(new MediaEvent(MediaEvent.JWPLAYER_MEDIA_LOADED));
        }

        /** Set the volume on init. **/
        override public function initializeMediaProvider(cfg : PlayerConfig) : void {
            super.initializeMediaProvider(cfg);
            _hls = new HLS();
            _hls.stage = RootReference.stage;
            _hls.stream.soundTransform = new SoundTransform(cfg.volume / 100);
            _hls.addEventListener(HLSEvent.PLAYBACK_COMPLETE, _completeHandler);
            _hls.addEventListener(HLSEvent.ERROR, _errorHandler);
            _hls.addEventListener(HLSEvent.FRAGMENT_LOADED, _fragmentHandler);
            _hls.addEventListener(HLSEvent.MANIFEST_LOADED, _manifestHandler);
            _hls.addEventListener(HLSEvent.PLAYBACK_STATE, _stateHandler);
            _hls.addEventListener(HLSEvent.AUDIO_ONLY, _audioHandler);

            // Allow stagevideo to be disabled by user config
            if (cfg.hasOwnProperty('stagevideo') && cfg['stagevideo'].toString() == "false") {
                _stageEnabled = false;
            }
            _video = new Video(1920, 960);
            _video.smoothing = true;
            // Use stageVideo when available
            if (_stageEnabled && RootReference.stage.stageVideos.length > 0) {
                _stageVideo = RootReference.stage.stageVideos[0];
                _stageVideo.viewPort = new Rectangle(0, 0, 1920, 960);
                _stageVideo.attachNetStream(_hls.stream);
                Log.info("stage video enabled");
            } else {
                _video.attachNetStream(_hls.stream);
            }

            _level = 0;
            var value : Object;

            // parse configuration parameters
            value = cfg.hls_debug;
            if (value != null) {
                Log.info("hls_debug:" + value);
                Log.LOG_DEBUG_ENABLED = value as Boolean;
            }

            value = cfg.hls_debug2;
            if (value != null) {
                Log.info("hls_debug2:" + value);
                Log.LOG_DEBUG2_ENABLED = value as Boolean;
            }

            value = cfg.hls_minbufferlength;
            if (value != null) {
                Log.info("hls_minbufferlength:" + value);
                _hls.minBufferLength = value as Number;
            }

            value = cfg.hls_maxbufferlength;
            if (value != null) {
                Log.info("hls_maxbufferlength:" + value);
                _hls.maxBufferLength = value as Number;
            }

            value = cfg.hls_lowbufferlength;
            if (value != null) {
                Log.info("hls_lowbufferlength:" + value);
                _hls.lowBufferLength = value as Number;
            }

            value = cfg.hls_startfromlowestlevel;
            if (value != null) {
                Log.info("hls_startfromlowestlevel:" + value);
                _hls.startFromLowestLevel = value as Boolean;
            }

            value = cfg.hls_seekfromlowestlevel;
            if (value != null) {
                Log.info("hls_seekfromlowestlevel:" + value);
                _hls.seekFromLowestLevel = value as Boolean;
            }

            value = cfg.hls_live_flushurlcache;
            if (value != null) {
                Log.info("hls_live_flushurlcache:" + value);
                _hls.flushLiveURLCache = value as Boolean;
            }

            value = cfg.hls_live_seekdurationthreshold;
            if (value != null) {
                Log.info("hls_live_seekdurationthreshold:" + value);
                _seekInLiveDurationThreshold = value as Number;
            }

            value = cfg.hls_seekmode;
            if (value != null) {
                Log.info("hls_seekmode:" + value);
                _hls.seekMode = value as String;
            }
            value = cfg.hls_fragmentloadmaxretry;
            if (value != null) {
                Log.info("hls_fragmentloadmaxretry:" + value);
                _hls.fragmentLoadMaxRetry = value as Number;
            }

            value = cfg.hls_manifestloadmaxretry;
            if (value != null) {
                Log.info("hls_manifestloadmaxretry:" + value);
                _hls.manifestLoadMaxRetry = value as Number;
            }

            value = cfg.hls_capleveltostage;
            if (value != null) {
                Log.info("hls_capleveltostage:" + value);
                if (value as Boolean == true) {
                    _hls.capLeveltoStage = true;
                }
            }
            mute(cfg.mute);
        };

        /** Check that Flash Player version is sufficient (10.1 or above) **/
        private function _checkVersion() : Number {
            var versionStr : String = Capabilities.version;
            var verArray : Array = versionStr.split(/\s|,/);
            var versionNum : Number = Number(String(verArray[1] + "." + verArray[2]));
            return versionNum;
        }

        /** Load a new playlist item **/
        override public function load(itm : PlaylistItem) : void {
            // Check flash player version
            var ver : Number = _checkVersion();
            var minVersion : Number = 11.6;
            if ( ver < minVersion ) {
                sendMediaEvent(MediaEvent.JWPLAYER_MEDIA_ERROR, {message:"This application requires Flash Player 11.6 at mimimum"});
            } else {
                super.load(itm);
                play();
            }
        };

        /** Get the video object. **/
        override public function get display() : DisplayObject {
            return _video;
        };

		public override function getRawMedia():DisplayObject
		{
			return display;

		}

        /** Resume playback of a paused item. **/
        override public function play() : void {
            if (state == PlayerState.PAUSED) {
                _hls.stream.resume();
            } else {
                setState(PlayerState.BUFFERING);
                _hls.load(item.file);
            }
        };

        /** Pause a playing item. **/
        override public function pause() : void {
            _hls.stream.pause();
        };

        /** Do a resize on the video. **/
        override public function resize(width : Number, height : Number) : void {
            Log.info("resize video from [" + _videoWidth + "," + _videoHeight + "]" + "to [" + width + "," + height + "]");
            _width = width;
            _height = height;
            if (_videoWidth && _videoHeight) {
                var rect : Rectangle = ScaleVideo.resizeRectangle(_videoWidth, _videoHeight, width, height);
                if (_stageVideo) {
                    _stageVideo.viewPort = rect;
                } else {
                    _video.x = rect.x;
                    _video.y = rect.y;
                    _video.width = rect.width;
                    _video.height = rect.height;
                }
            }
        };

        /** Seek to a certain position in the item. **/
        override public function seek(pos : Number) : void {
            _hls.stream.seek(pos);
        };

        /** Change the playback volume of the item. **/
        override public function setVolume(vol : Number) : void {
            _hls.stream.soundTransform = new SoundTransform(vol / 100);
            super.setVolume(vol);
        };

        /** Stop playback. **/
        override public function stop() : void {
            _hls.stream.close();
            super.stop();
            _hls.removeEventListener(HLSEvent.MEDIA_TIME, _mediaTimeHandler);
            _level = 0;
        };
    }
}

Create Video element using 1920x960 resolution.


package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.render.Effect;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.scene.RenderingController;
	import aerys.minko.scene.node.camera.AbstractCamera;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.binding.DataProvider;
	import aerys.minko.type.enum.DataProviderUsage;
	import aerys.minko.type.loader.AssetsLibrary;

	import flash.display.BitmapData;
	import flash.utils.Dictionary;
	import flash.utils.getTimer;

	/**
	 * Scene objects are the root of any 3D scene.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class Scene extends Group
	{
		use namespace minko_scene;

		minko_scene var _camera		: AbstractCamera;

		private var _renderingCtrl	: RenderingController;

		private var _properties		: DataProvider;
		private var _bindings		: DataBindings;

		private var _numTriangles	: uint;

		private var _enterFrame		: Signal;
		private var _renderingBegin	: Signal;
		private var _renderingEnd	: Signal;
		private var _exitFrame		: Signal;

		private var _assets			: AssetsLibrary;

		public function get assets() : AssetsLibrary
		{
			return _assets;
		}

		public function get activeCamera() : AbstractCamera
		{
			return _camera;
		}

		public function get numPasses() : uint
		{
			return _renderingCtrl.numPasses;
		}

		public function get numEnabledPasses() : uint
		{
			return _renderingCtrl.numEnabledPasses;
		}

		public function get numDrawCalls() : uint
		{
			return _renderingCtrl.numDrawCalls;
		}

		public function get numEnabledDrawCalls() : uint
		{
			return _renderingCtrl.numEnabledDrawCalls;
		}

		public function get numTriangles() : uint
		{
			return _numTriangles;
		}

		public function get numDrawCalls() : uint
		{
			return _renderingCtrl.numDrawCalls;
		}

		public function get postProcessingEffect() : Effect
		{
			return _renderingCtrl.postProcessingEffect;
		}
		public function set postProcessingEffect(value : Effect) : void
		{
			_renderingCtrl.postProcessingEffect = value;
		}

		public function get postProcessingProperties() : DataProvider
		{
			return _renderingCtrl.postProcessingProperties;
		}

		public function get properties() : DataProvider
		{
			return _properties;
		}
		public function set properties(value : DataProvider) : void
		{
			if (_properties != value)
			{
				if (_properties)
					_bindings.removeProvider(_properties);

				_properties = value;

				if (value)
					_bindings.addProvider(value);
			}
		}

		public function get bindings() : DataBindings
		{
			return _bindings;
		}

		/**
		 * The signal executed when the viewport is about to start rendering a frame.
		 * Callback functions for this signal should accept the following arguments:
		 *

		 *
viewport : Viewport, the viewport who starts rendering the frame

		 *

		 * @return
		 *
		 */
		public function get enterFrame() : Signal
		{
			return _enterFrame;
		}

		/**
		 * The signal executed when the viewport is done rendering a frame.
		 * Callback functions for this signal should accept the following arguments:
		 *

		 *
viewport : Viewport, the viewport who just finished rendering the frame

		 *

		 * @return
		 *
		 */
		public function get exitFrame() : Signal
		{
			return _exitFrame;
		}

		public function get renderingBegin() : Signal
		{
			return _renderingBegin;
		}

		public function get renderingEnd() : Signal
		{
			return _renderingEnd;
		}

		public function Scene(...children)
		{
			super(children);
		}

		override protected function initialize() : void
		{
			_bindings 					= new DataBindings(this);
			_assets						= new AssetsLibrary();
			this.properties 			= new DataProvider(DataProviderUsage.EXCLUSIVE);

			super.initialize();
		}

		override protected function initializeSignals() : void
		{
			super.initializeSignals();

			_enterFrame			= new Signal('Scene.enterFrame');
			_renderingBegin 	= new Signal('Scene.renderingBegin');
			_renderingEnd 		= new Signal('Scene.renderingEnd');
			_exitFrame 			= new Signal('Scene.exitFrame');
		}

		override protected function initializeSignalHandlers() : void
		{
			super.initializeSignalHandlers();

			added.add(addedHandler);
		}

		override protected function initializeContollers() : void
		{
			_renderingCtrl = new RenderingController();
			addController(_renderingCtrl);

			super.initializeContollers();
		}

		public function render(viewport : Viewport, destination : BitmapData = null) : void
		{
			_enterFrame.execute(this, viewport, destination, getTimer());
			if (viewport.ready && viewport.visible)
			{
				_renderingBegin.execute(this, viewport, destination, getTimer());
				_numTriangles = _renderingCtrl.render(viewport, destination);
				_renderingEnd.execute(this, viewport, destination, getTimer());
			}
			_exitFrame.execute(this, viewport, destination, getTimer());
		}

		private function addedHandler(child : ISceneNode, parent : Group) : void
		{
			throw new Error();
		}
	}
}

package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.render.Effect;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.scene.RenderingController;
	import aerys.minko.scene.node.camera.AbstractCamera;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.binding.DataProvider;
	import aerys.minko.type.enum.DataProviderUsage;
	import aerys.minko.type.loader.AssetsLibrary;

	import flash.display.BitmapData;
	import flash.utils.Dictionary;
	import flash.utils.getTimer;

	/**
	 * Scene objects are the root of any 3D scene.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class Scene extends Group
	{
		use namespace minko_scene;

		minko_scene var _camera		: AbstractCamera;

		private var _renderingCtrl	: RenderingController;

		private var _properties		: DataProvider;
		private var _bindings		: DataBindings;

		private var _numTriangles	: uint;

		private var _enterFrame		: Signal;
		private var _renderingBegin	: Signal;
		private var _renderingEnd	: Signal;
		private var _exitFrame		: Signal;

		private var _assets			: AssetsLibrary;

		public function get assets() : AssetsLibrary
		{
			return _assets;
		}

		public function get activeCamera() : AbstractCamera
		{
			return _camera;
		}

		public function get numPasses() : uint
		{
			return _renderingCtrl.numPasses;
		}

		public function get numEnabledPasses() : uint
		{
			return _renderingCtrl.numEnabledPasses;
		}

		public function get numDrawCalls() : uint
		{
			return _renderingCtrl.numDrawCalls;
		}

		public function get numEnabledDrawCalls() : uint
		{
			return _renderingCtrl.numEnabledDrawCalls;
		}

		public function get numTriangles() : uint
		{
			return _numTriangles;
		}

		public function get postProcessingEffect() : Effect
		{
			return _renderingCtrl.postProcessingEffect;
		}
		public function set postProcessingEffect(value : Effect) : void
		{
			_renderingCtrl.postProcessingEffect = value;
		}

		public function get postProcessingProperties() : DataProvider
		{
			return _renderingCtrl.postProcessingProperties;
		}

		public function get properties() : DataProvider
		{
			return _properties;
		}
		public function set properties(value : DataProvider) : void
		{
			if (_properties != value)
			{
				if (_properties)
					_bindings.removeProvider(_properties);

				_properties = value;

				if (value)
					_bindings.addProvider(value);
			}
		}

		public function get bindings() : DataBindings
		{
			return _bindings;
		}

		/**
		 * The signal executed when the viewport is about to start rendering a frame.
		 * Callback functions for this signal should accept the following arguments:
		 *

		 *
viewport : Viewport, the viewport who starts rendering the frame

		 *

		 * @return
		 *
		 */
		public function get enterFrame() : Signal
		{
			return _enterFrame;
		}

		/**
		 * The signal executed when the viewport is done rendering a frame.
		 * Callback functions for this signal should accept the following arguments:
		 *

		 *
viewport : Viewport, the viewport who just finished rendering the frame

		 *

		 * @return
		 *
		 */
		public function get exitFrame() : Signal
		{
			return _exitFrame;
		}

		public function get renderingBegin() : Signal
		{
			return _renderingBegin;
		}

		public function get renderingEnd() : Signal
		{
			return _renderingEnd;
		}

		public function Scene(...children)
		{
			super(children);
		}

		override protected function initialize() : void
		{
			_bindings 					= new DataBindings(this);
			_assets						= new AssetsLibrary();
			this.properties 			= new DataProvider(DataProviderUsage.EXCLUSIVE);

			super.initialize();
		}

		override protected function initializeSignals() : void
		{
			super.initializeSignals();

			_enterFrame			= new Signal('Scene.enterFrame');
			_renderingBegin 	= new Signal('Scene.renderingBegin');
			_renderingEnd 		= new Signal('Scene.renderingEnd');
			_exitFrame 			= new Signal('Scene.exitFrame');
		}

		override protected function initializeSignalHandlers() : void
		{
			super.initializeSignalHandlers();

			added.add(addedHandler);
		}

		override protected function initializeContollers() : void
		{
			_renderingCtrl = new RenderingController();
			addController(_renderingCtrl);

			super.initializeContollers();
		}

		public function render(viewport : Viewport, destination : BitmapData = null) : void
		{
			_enterFrame.execute(this, viewport, destination, getTimer());
			if (viewport.ready && viewport.visible)
			{
				_renderingBegin.execute(this, viewport, destination, getTimer());
				_numTriangles = _renderingCtrl.render(viewport, destination);
				_renderingEnd.execute(this, viewport, destination, getTimer());
			}
			_exitFrame.execute(this, viewport, destination, getTimer());
		}

		private function addedHandler(child : ISceneNode, parent : Group) : void
		{
			throw new Error();
		}
	}
}

fix duplicate function definition for Scene.numDrawCalls getter