fixed tree folder arrow visibility bug

fixed tree folder arrow visibility bug

--- WeaveUI/src/weave/ui/CustomTree.as
+++ WeaveUI/src/weave/ui/CustomTree.as
@@ -25,14 +25,20 @@
 	import mx.collections.IList;
 	import mx.collections.IViewCursor;
 	import mx.controls.Tree;
+	import mx.controls.treeClasses.TreeListData;
 	import mx.core.ScrollPolicy;
 	import mx.core.mx_internal;
 	import mx.utils.ObjectUtil;

 	import weave.utils.EventUtils;

+	use namespace mx_internal;
+
 	/**
-	 * This class features a correctly behaving auto scroll policy and scrollToIndex().
+	 * This class features:

+	 * - correctly behaving auto scroll policy and scrollToIndex()

+	 * - fixes folder arrow visibility bug

+	 * - useful functions like refreshDataProvider()
 	 * @author adufilie
 	 */
 	public class CustomTree extends Tree
@@ -41,6 +47,15 @@
 		{
 			super();
 			addEventListener("scroll", updateHScrollLater);
+		}
+
+		override protected function initListData(item:Object, treeListData:TreeListData):void
+		{
+			super.initListData(item, treeListData);
+
+			// this makes the folder arrow hide when there are no children
+			// This is a bug fix - Tree is supposed to do this but instead it uses isBranch()
+			treeListData.hasChildren = item != null && _dataDescriptor.hasChildren(item, iterator.view);
 		}

 		///////////////////////////////////////////////////////////////////////////////


pitch,rollスライダを非表示に・tiltフィルタ動作を無効化.

pitch,rollスライダを非表示に・tiltフィルタ動作を無効化.

--- src/EquirectangularMergePlayer.as
+++ src/EquirectangularMergePlayer.as
@@ -77,6 +77,7 @@
 		//protected var _tiltMaterial:AGALTiltMaterial
 		protected function tilt(yaw:Number, pitch:Number, roll:Number):void
 		{
+			/*
 			if (_tiltResult) {
 				_parent.removeChild(_tiltResult);
 			}
@@ -96,6 +97,7 @@
 			_parent.addChild(_tiltResult);

 			//_tiltMaterial.setCompass(yaw, pitch, roll);
+			*/
 		}

 		//protected var _plane:Plane;
@@ -211,8 +213,8 @@
 			sliderP.y = 64 + 40;
 			sliderR.y = 64 + 40 * 2;
 			_parent.addChild(sliderY);
-			_parent.addChild(sliderP);
-			_parent.addChild(sliderR);
+			_parent.addChild(sliderP);	sliderP.visible = false;
+			_parent.addChild(sliderR);	sliderR.visible = false;

 			var enable_controller:Function = function():void {
 				_controller.enable();


no longer showing full stack trace in WeaveAPI debug message

--- WeaveAPI/src/weave/api/WeaveAPI.as
+++ WeaveAPI/src/weave/api/WeaveAPI.as
@@ -344,7 +344,8 @@
 		 */
 		public static function getSingletonInstance(singletonInterface:Class):*
 		{
-			// TEMPORARY SOLUTION until everything is a plug-in.
+			///////////////////////
+			// TEMPORARY SOLUTION (until everything is a plug-in.)
 			if (!_initialized)
 			{
 				_initialized = true;
@@ -357,9 +358,11 @@
 				}
 				catch (e:Error)
 				{
-					trace(e.getStackTrace());
-				}
-			}
+					trace(e.message);
+				}
+			}
+			// END TEMPORARY SOLUTION
+			///////////////////////////

 			var result:* = _singletonDictionary[singletonInterface];
 			// If no instance has been created yet, create one now.


added most recent device

added most recent device

added a signal/member recent device, which dispatches anytime a
different device sends an update

--- src/com/zehfernando/input/binding/KeyActionBinder.as
+++ src/com/zehfernando/input/binding/KeyActionBinder.as
@@ -24,6 +24,8 @@
 		// Constants
 		public static const VERSION:String = "1.8.7";

+		public static const KEYBOARD_DEVICE:GameInputDevice=null; // is set to null, since gamepads are non-null (and you can't create/subclass a GameInputDevice)
+
 		[Embed(source = "controllers.json", mimeType='application/octet-stream')]
 		private static const JSON_CONTROLLERS:Class;

@@ -36,6 +38,7 @@
 		private var _isRunning:Boolean;
 		private var _alwaysPreventDefault:Boolean;						// If true, prevent action by other keys all the time (e.g. menu key)
 		private var _maintainPlayerPositions:Boolean;					// Whether it tries to keep player positions or not
+		private var _recentDevice:GameInputDevice;						// the most recent device that sent an event

 		// Instances
 		private var bindings:Vector.<BindingInfo>;						// Actual existing bindings, their action, and whether they're activated or not
@@ -45,6 +48,7 @@
 		private var _onActionDeactivated:SimpleSignal;					// Receives: action:String
 		private var _onActionValueChanged:SimpleSignal;					// Receives: action:String, value:Number (0-1)
 		private var _onDevicesChanged:SimpleSignal;
+		private var _onRecentDevice:SimpleSignal;						//  Receives: recentDevice:GameInputDevice

 		private var gameInputDevices:Vector.<GameInputDevice>;
 		private var gameInputDeviceIds:Vector.<String>;
@@ -214,6 +218,7 @@
 			_onActionDeactivated = new SimpleSignal();
 			_onActionValueChanged = new SimpleSignal();
 			_onDevicesChanged = new SimpleSignal();
+			_onRecentDevice = new SimpleSignal();

 			gameInputDevices = new Vector.<GameInputDevice>();
 			gameInputDeviceIds = new Vector.<String>();
@@ -469,7 +474,10 @@
 						activationInfo.addActivation(filteredControls[i], __gamepadIndex);

 						// Dispatches signal
-						if (activationInfo.getNumActivations() == 1) _onActionActivated.dispatch(filteredControls[i].action);
+						if (activationInfo.getNumActivations() == 1) {
+							recentDevice = gameInputDevices[__gamepadIndex]
+							_onActionActivated.dispatch(filteredControls[i].action);
+						}
 					} else {
 						// Marks as released

@@ -477,9 +485,12 @@
 						activationInfo.removeActivation(filteredControls[i]);

 						// Dispatches signal
-						if (activationInfo.getNumActivations() == 0) _onActionDeactivated.dispatch(filteredControls[i].action);
+						if (activationInfo.getNumActivations() == 0) {
+							recentDevice = gameInputDevices[__gamepadIndex];
+							_onActionDeactivated.dispatch(filteredControls[i].action);
 						}
 					}
+				}
 			}
 		}

@@ -515,6 +526,7 @@

 					// Dispatches signal
 					if ((actionsActivations[filteredKeys[i].action] as ActivationInfo).getNumActivations() == 1) {
+						recentDevice = KEYBOARD_DEVICE;
 						_onActionValueChanged.dispatch(filteredKeys[i].action, 1);
 						_onActionActivated.dispatch(filteredKeys[i].action);
 					}
@@ -550,6 +562,7 @@

 				// Dispatches signal
 				if ((actionsActivations[filteredKeys[i].action] as ActivationInfo).getNumActivations() == 0) {
+					recentDevice = KEYBOARD_DEVICE;
 					_onActionValueChanged.dispatch(filteredKeys[i].action, 0);
 					_onActionDeactivated.dispatch(filteredKeys[i].action);
 				}
@@ -610,6 +623,12 @@
 			}
 		}

+        private function set recentDevice(value:GameInputDevice):void {
+            if(_recentDevice != value) {
+                _recentDevice = value;
+                _onRecentDevice.dispatch(value);
+            }
+        }

 		// ================================================================================================================
 		// PUBLIC INTERFACE -----------------------------------------------------------------------------------------------
@@ -878,6 +897,10 @@
 			return _onDevicesChanged;
 		}

+		public function get onRecentDevice():SimpleSignal {
+			return _onRecentDevice;
+		}
+
 		/**
 		 * Toggles whether KeyActionBinder tries to maintain each player's gamepad index based on the unique id of each
 		 * device.
@@ -1028,6 +1051,7 @@
 }
 import flash.utils.Dictionary;
 import flash.utils.getTimer;
+
 /**
  * Information listing all activated bindings of a given action
  */
@@ -1298,4 +1322,3 @@
 	public function AutoGamepadControlKeyInfo() {
 	}
 }
-


Added gamepad index filter support for isActionActivated() and getActionValue()

--- src/com/zehfernando/input/binding/KeyActionBinder.as
+++ src/com/zehfernando/input/binding/KeyActionBinder.as
@@ -62,7 +62,6 @@
 		private var gameInputDeviceDefinitions:Vector.<AutoGamepadInfo>;

 		private static var gameInput:GameInput;
-

 		// Properties to avoid allocations
 		private var mi:Number;											// Used in map()
@@ -543,7 +542,7 @@
 						// A sensitive binding, send changed value signals instead

 						// Dispatches signal
-						activationInfo.addSensitiveValue(filteredControls[i].action, map(control.value, control.minValue, control.maxValue, deviceControlInfo.min, deviceControlInfo.max, true));
+						activationInfo.addSensitiveValue(filteredControls[i].action, map(control.value, control.minValue, control.maxValue, deviceControlInfo.min, deviceControlInfo.max, true), deviceIndex);
 						_onSensitiveActionChanged.dispatch(filteredControls[i].action, activationInfo.getValue());
 					} else {
 						// A standard action binding, send activated/deactivated signals
@@ -556,7 +555,7 @@
 								filteredControls[i].lastActivatedTime = getTimer();

 								// Add this activation to the list of current activations
-								activationInfo.addActivation(filteredControls[i]);
+								activationInfo.addActivation(filteredControls[i], deviceIndex);

 								// Dispatches signal
 								if (activationInfo.getNumActivations() == 1) _onActionActivated.dispatch(filteredControls[i].action);
@@ -783,8 +782,8 @@
 		 * @see #addGamepadSensitiveActionBinding()
 		 * @see #isActionActivated()
 		 */
-		public function getActionValue(__action:String):Number {
-			return actionsActivations.hasOwnProperty(__action) ? (actionsActivations[__action] as ActivationInfo).getValue() : 0;
+		public function getActionValue(__action:String, __gamepadIndex:int = -1):Number {
+			return actionsActivations.hasOwnProperty(__action) ? (actionsActivations[__action] as ActivationInfo).getValue(__gamepadIndex) : 0;
 		}

 		/**
@@ -817,7 +816,7 @@
 		 * @see #getActionValue()
 		 */
 		public function isActionActivated(__action:String, __timeToleranceSeconds:Number = 0, __gamepadIndex:int = -1):Boolean {
-			return actionsActivations.hasOwnProperty(__action) && (actionsActivations[__action] as ActivationInfo).getNumActivations(__timeToleranceSeconds) > 0;
+			return actionsActivations.hasOwnProperty(__action) && (actionsActivations[__action] as ActivationInfo).getNumActivations(__timeToleranceSeconds, __gamepadIndex) > 0;
 		}

 		/**
@@ -875,7 +874,9 @@
 class ActivationInfo {

 	private var activations:Vector.<BindingInfo>;			// All activated bindings
+	private var activationGamepadIndexes:Vector.<int>;		// Gamepad that activated that binding
 	private var sensitiveValues:Dictionary;					// Dictionary with IBinding
+	private var sensitiveValuesGamepadIndexes:Dictionary;	// Gamepad int that activated that sensitive value

 	// Temp vars to avoid garbage collection
 	private var iiv:Number;									// Value buffer
@@ -890,7 +891,9 @@

 	public function ActivationInfo() {
 		activations = new Vector.<BindingInfo>();
+		activationGamepadIndexes = new Vector.<int>();
 		sensitiveValues = new Dictionary();
+		sensitiveValuesGamepadIndexes = new Dictionary();
 	}

 	// ================================================================================================================
@@ -898,42 +901,46 @@

 	public function addActivation(__bindingInfo:BindingInfo, __gamepadIndex:int = -1):void {
 		activations.push(__bindingInfo);
+		activationGamepadIndexes.push(__gamepadIndex);
 	}

 	public function removeActivation(__bindingInfo:BindingInfo):void {
 		iix = activations.indexOf(__bindingInfo);
 		if (iix > -1) {
 			activations.splice(iix, 1);
-		}
-	}
-
-	public function getNumActivations(__timeToleranceSeconds:Number = 0):int {
+			activationGamepadIndexes.splice(iix, 1);
+		}
+	}
+
+	public function getNumActivations(__timeToleranceSeconds:Number = 0, __gamepadIndex:int = -1):int {
 		// If not time-sensitive, just return it
-		if (__timeToleranceSeconds <= 0 || activations.length == 0) return activations.length;
-		// Otherwise, actually check for activation time
+		if ((__timeToleranceSeconds <= 0 && __gamepadIndex < 0) || activations.length == 0) return activations.length;
+		// Otherwise, actually check for activation time and gamepad index
 		iit = getTimer() - __timeToleranceSeconds * 1000;
 		iic = 0;
 		for (iii = 0; iii < activations.length; iii++) {
-			if (activations[iii].lastActivatedTime >= iit) iic++;
+			if ((__timeToleranceSeconds <= 0 || activations[iii].lastActivatedTime >= iit) && (__gamepadIndex < 0 || activationGamepadIndexes[iii] == __gamepadIndex)) iic++;
 		}
 		return iic;
 	}

 	public function resetActivations():void {
 		activations.length = 0;
-	}
-
-	public function addSensitiveValue(__actionId:String, __value:Number):void {
+		activationGamepadIndexes.length = 0;
+	}
+
+	public function addSensitiveValue(__actionId:String, __value:Number, __gamepadIndex:int = -1):void {
 		sensitiveValues[__actionId] = __value;
-	}
-
-	public function getValue():Number {
+		sensitiveValuesGamepadIndexes[__actionId] = __gamepadIndex;
+	}
+
+	public function getValue(__gamepadIndex:int = -1):Number {
 		iiv = NaN;
 		for (iis in sensitiveValues) {
-			// NOTE: this will be a problem if two axis control the same action, since +1 is not necessarily better than -1
-			if (isNaN(iiv) || sensitiveValues[iis] > iiv) iiv = sensitiveValues[iis];
-		}
-		if (isNaN(iiv)) return activations.length == 0 ? 0 : 1;
+			// NOTE: this may be a problem if two different axis control the same action, since -1 is not necessarily better than +0.5
+			if ((__gamepadIndex < 0 || sensitiveValuesGamepadIndexes[iis] == __gamepadIndex) && (isNaN(iiv) || Math.abs(sensitiveValues[iis]) > Math.abs(iiv))) iiv = sensitiveValues[iis];
+		}
+		if (isNaN(iiv)) return getNumActivations(0, __gamepadIndex) == 0 ? 0 : 1;
 		return iiv;
 	}
 }


Transferred from the Adobe Open Source Subversion Repository

Revision: 20219
Author:   dthakkar@adobe.com
Date:     2011-02-09T00:31:57.411477Z

Log Message:
-----------
QE notes:
Doc notes: Added alternative metatag
Bugs: SDK-28163
Reviewer: Masa,Harish
Tests run: Cyclone
Is noteworthy for integration: No

Modified Paths:
--------------
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/validators/CurrencyValidator.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/collections/SortField.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/formatters/NumberFormatter.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/formatters/CurrencyFormatter.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/collections/Sort.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/validators/NumberValidator.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/framework/src/mx/formatters/DateFormatter.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1260834 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/framework/src/mx/formatters/CurrencyFormatter.as
+++ frameworks/projects/framework/src/mx/formatters/CurrencyFormatter.as
@@ -18,6 +18,7 @@
 [ResourceBundle("formatters")]
 [ResourceBundle("SharedResources")]

+[Alternative(replacement="spark.formatters.CurrencyFormatter", since="4.5")]
 /**
  *  The CurrencyFormatter class formats a valid number as a currency value.
  *  It adjusts the decimal rounding and precision, the thousands separator,


added parsing error event

added parsing error event

--- RNLib/src/rnlib/net/amf/connections/AMFURLLoader.as
+++ RNLib/src/rnlib/net/amf/connections/AMFURLLoader.as
@@ -275,9 +275,9 @@
 				var response:AMFPacket = AMFProcessor.decodeResponse(data);
 			} catch (e:Error)
 			{
-				_fault(data);
 				if (_redispatcher)
 					_redispatcher.dispatchEvent(new AMFEvent(AMFEvent.PARSE_ERROR, 1, data));
+				_fault(data);
 				dispose();
 				return;
 			}


added more debug code

added more debug code

Change-Id: Ib5bd79f2721954ebd19407128c28fc370909f6eb

--- WeaveCore/src/weave/core/SessionStateLog.as
+++ WeaveCore/src/weave/core/SessionStateLog.as
@@ -79,6 +79,13 @@
 				_savePending = true;
 				saveDiff();
 			}
+
+			if (debug && (_undoActive || _redoActive))
+			{
+				var state:Object = getSessionState(_subject);
+				var forwardDiff:* = WeaveAPI.SessionManager.computeDiff(_prevState, state);
+				trace('immediate diff:', ObjectUtil.toString(forwardDiff));
+			}
 		}

 		private function groupedCallback():void
@@ -88,6 +95,13 @@
 			// It is ok to save a diff the frame after grouped callbacks are called.
 			// If callbacks are triggered again before the next frame, the immediateCallback will set this flag back to true.
 			_saveLater = false;
+
+			if (debug && (_undoActive || _redoActive))
+			{
+				var state:Object = getSessionState(_subject);
+				var forwardDiff:* = WeaveAPI.SessionManager.computeDiff(_prevState, state);
+				trace('grouped diff:', ObjectUtil.toString(forwardDiff));
+			}
 		}

 		private function saveDiff(immediately:Boolean = false):void
@@ -188,6 +202,13 @@
 					if (stepsRemaining == 0)
 						_prevState = getSessionState(_subject);
 					setSessionState(_subject, diff, false);
+
+					if (debug)
+					{
+						var newState:Object = getSessionState(_subject);
+						var resultDiff:Object = WeaveAPI.SessionManager.computeDiff(_prevState, newState);
+						trace('resulting diff:', ObjectUtil.toString(resultDiff));
+					}
 				}
 				getCallbackCollection(_subject).resumeCallbacks();


Update idiomesAnimation.as

Update idiomesAnimation.as

--- com/segonquart/idiomesAnimation.as
+++ com/segonquart/idiomesAnimation.as
@@ -15,7 +15,7 @@

 		}

-	private function enterSlide():Void
+	private function enterSlide()
                 {

 			arrayLang_arr[0].slideTo('0', '-40', 0.6, 'easeInOutBack', 1);
@@ -27,7 +27,7 @@

 		}

-	public function IdiomesColour():Void
+	public function IdiomesColour()
 		{

 			this.onRelease = this arrayColour;
@@ -39,7 +39,7 @@

 		}

-	private function arrayColour():Void
+	private function arrayColour()
 		{

 			for ( var:i ; arrayLang_arr[i] <4; i++)


rely on the signal auto disable feature when (un)subscribing to(from) joints

--- src/aerys/minko/scene/controller/mesh/skinning/SkinningController.as
+++ src/aerys/minko/scene/controller/mesh/skinning/SkinningController.as
@@ -179,43 +179,24 @@

 		private function subscribeToJoints() : void
 		{
-			var numJoints						: uint 		= _joints.length;
-			var localToWorldTransformChanged 	: Signal 	= null;
-
-			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
-			{
-				localToWorldTransformChanged = _joints[jointId].localToWorldTransformChanged;
-				localToWorldTransformChanged.add(jointLocalToWorldChangedHandler);
-				localToWorldTransformChanged.enabled = true;
-			}
+			var numJoints	: uint	= _joints.length;
+
+			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
+				_joints[jointId].localToWorldTransformChanged.add(jointLocalToWorldChangedHandler);

 			if (_joints.indexOf(_skeletonRoot) == -1)
-			{
-				localToWorldTransformChanged = _skeletonRoot.localToWorldTransformChanged;
-				localToWorldTransformChanged.add(jointLocalToWorldChangedHandler);
-				localToWorldTransformChanged.enabled = true;
-			}
+				_skeletonRoot.localToWorldTransformChanged.add(jointLocalToWorldChangedHandler);
 		}

 		private function unsubscribeFromJoints() : void
 		{
-			var numJoints						: uint 		= _joints.length;
-			var localToWorldTransformChanged 	: Signal 	= null;
-
-			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
-			{
-				localToWorldTransformChanged = _joints[jointId].localToWorldTransformChanged;
-				localToWorldTransformChanged.remove(jointLocalToWorldChangedHandler);
-				localToWorldTransformChanged.enabled = !!localToWorldTransformChanged.numCallbacks;
-			}
+			var numJoints	: uint	= _joints.length;
+
+			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
+				_joints[jointId].localToWorldTransformChanged.remove(jointLocalToWorldChangedHandler);

 			if (_joints.indexOf(_skeletonRoot) == -1)
-			{
-				localToWorldTransformChanged = _skeletonRoot.localToWorldTransformChanged;
-				localToWorldTransformChanged.remove(jointLocalToWorldChangedHandler);
-				localToWorldTransformChanged.enabled = !!localToWorldTransformChanged.numCallbacks;
-			}
-
+				_skeletonRoot.localToWorldTransformChanged.remove(jointLocalToWorldChangedHandler);
 		}

 		override protected function sceneEnterFrameHandler(scene		: Scene,


fix typo

fix typo

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


Movie calls advanceTime on Layers, which only call advanceTime on currentDisplay

--- runtime/src/main/as/flump/display/Movie.as
+++ runtime/src/main/as/flump/display/Movie.as
@@ -194,11 +194,8 @@
             updateFrame(newFrame, dt);
         }

-        for (var ii :int = this.numChildren - 1; ii >= 0; --ii) {
-            var child :DisplayObject = getChildAt(ii);
-            if (child is Movie) {
-                Movie(child).advanceTime(dt);
-            }
+        for (var ii :int = _layers.length - 1; ii >= 0; --ii) {
+            _layers[ii].advanceTime(dt);
         }
     }


add comments for NAL unit parsing

add comments for NAL unit parsing

--- src/com/mangui/HLS/muxing/AVC.as
+++ src/com/mangui/HLS/muxing/AVC.as
@@ -52,19 +52,24 @@
             } else if (pps == -1) {
                 throw new Error("No PPS NAL unit found in this stream.");
             }
-            // Write startbyte, profile, compatibility and level.
+            // Write startbyte
             var avcc:ByteArray = new ByteArray();
             avcc.writeByte(0x01);
+            // Write profile, compatibility and level.
             avcc.writeBytes(nalu,units[sps].start+1, 3);
-            // 111111 + NALU bytesize length (4?)
-            avcc.writeByte(0xFF);
-            // Number of SPS, Bytesize and data.
-            avcc.writeByte(0xE1);
+            // reserved (6 bits), NALU length size - 1 (2 bits)
+            avcc.writeByte(0xFC | 3);
+            // reserved (3 bits), num of SPS (5 bits)
+            avcc.writeByte(0xE0 | 1);
+            // 2 bytes for length of SPS
             avcc.writeShort(units[sps].length);
+            // data of SPS
             avcc.writeBytes(nalu,units[sps].start,units[sps].length);
-            // Number of PPS, Bytesize and data.
+            // Number of PPS
             avcc.writeByte(0x01);
+            // 2 bytes for length of PPS
             avcc.writeShort(units[pps].length);
+            // data of PPS
             avcc.writeBytes(nalu,units[pps].start,units[pps].length);
             // Grab profile/level
             avcc.position = 1;
@@ -100,6 +105,7 @@
                     unit_header = 4;
                     unit_start = nalu.position;
                     unit_type = nalu.readByte() & 0x1F;
+                    // NDR or IDR NAL unit
                     if(unit_type == 1 || unit_type == 5) { break; }
                 // Match three-byte startcodes
                 } else if((window & 0xFFFFFF00) == 0x100) {
@@ -115,6 +121,7 @@
                     unit_header = 3;
                     unit_start = nalu.position;
                     unit_type = nalu.readByte() & 0x1F;
+                    // NDR or IDR NAL unit
                     if(unit_type == 1 || unit_type == 5) { break; }
                 } else {
                     nalu.position -= 3;


- formatted TreeGrid so next commit is not drowned in formatting changes

--- src/flexlib/controls/TreeGrid.as
+++ src/flexlib/controls/TreeGrid.as
@@ -1,1095 +1,1122 @@
 /*
-Copyright (c) 2007 FlexLib Contributors.  See:
-	http://code.google.com/p/flexlib/wiki/ProjectContributors
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
+   Copyright (c) 2007 FlexLib Contributors.  See:
+   http://code.google.com/p/flexlib/wiki/ProjectContributors
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy of
+   this software and associated documentation files (the "Software"), to deal in
+   the Software without restriction, including without limitation the rights to
+   use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+   of the Software, and to permit persons to whom the Software is furnished to do
+   so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in all
+   copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+   SOFTWARE.
+ */

 package flexlib.controls
 {

-import flash.events.Event;
-import flash.events.KeyboardEvent;
-import flash.ui.Keyboard;
-import flash.xml.XMLNode;
-
-import flexlib.controls.treeGridClasses.TreeGridListData;
-
-import mx.collections.ArrayCollection;
-import mx.collections.ICollectionView;
-import mx.collections.IViewCursor;
-import mx.collections.ListCollectionView;
-import mx.collections.Sort;
-import mx.collections.SortField;
-import mx.collections.XMLListCollection;
-import mx.controls.DataGrid;
-import mx.controls.dataGridClasses.DataGridColumn;
-import mx.controls.listClasses.BaseListData;
-import mx.controls.listClasses.IListItemRenderer;
-import mx.controls.treeClasses.DefaultDataDescriptor;
-import mx.controls.treeClasses.ITreeDataDescriptor2;
-import mx.events.CollectionEvent;
-import mx.events.CollectionEventKind;
-import mx.events.DataGridEvent;
-import mx.utils.UIDUtil;
-import mx.controls.treeClasses.ITreeDataDescriptor;
-import flash.events.MouseEvent;
-import mx.events.ListEvent;
-
-
-[Style(name="disclosureOpenIcon", type="Class", format="EmbeddedFile", inherit="no")]
-
-[Style(name="disclosureClosedIcon", type="Class", format="EmbeddedFile", inherit="no")]
-
-[Style(name="folderOpenIcon", type="Class", format="EmbeddedFile", inherit="no")]
-
-[Style(name="folderClosedIcon", type="Class", format="EmbeddedFile", inherit="no")]
-
-[Style(name="defaultLeafIcon", type="Class", format="EmbeddedFile", inherit="no")]
-
-[Style(name="indentation", type="Number", inherit="no")]
-
-[Style(name="verticalTrunks", type="String", enumeration="none,normal,dotted", inherit="no")]
-
-[Style(name="trunkColor", type="uint", format="Color", inherit="yes")]
-
-/**
- *
- */
-public class TreeGrid extends DataGrid
-{
-
-	[Embed(source='../assets/defaultTreeAssets.swf#TreeDisclosureClosed')]
-	private var defaultDisclosureClosedClass:Class;
-
-	[Embed(source='../assets/defaultTreeAssets.swf#TreeDisclosureOpen')]
-	private var defaultDisclosureOpenClass:Class;
-
-	/**
-	 *  @private
-	 *  Used to hold a list of items that are opened or set opened.
-	 */
-	private var _openItems : Object = {};
-
-
-	/**
-	 *  An object that specifies the icons for the items.
-	 *  Each entry in the object has a field name that is the item UID
-	 *  and a value that is an an object with the following format:
-	 *

-	 *  {iconID: Class, iconID2: Class}
-	 *

-	 *  The iconID field value is the class of the icon for
-	 *  a closed or leaf item and the iconID2 is the class
-	 *  of the icon for an open item.
-	 *
-	 *
This property is intended to allow initialization of item icons.
-	 *  Changes to this array after initialization are not detected
-	 *  automatically.
-	 *  Use the setItemIcon() method to change icons dynamically.

-	 *
-	 *  @see #setItemIcon()
-	 *  @default undefined
-	 */
-	public var itemIcons : Object;
-
-	/**
-	 *  @private
-	 *  Storage variable for showRoot flag.
-	 */
-	private var _showRoot : Boolean = true;
-
-	/**
-	 *  @private
-	 *  Storage variable for changes to showRoot.
-	 */
-	private var showRootChanged : Boolean = false;
-
-	/**
-	*  @private
-	*  Flag to indicate if the model has a root
-	*/
-	private var _hasRoot : Boolean = false;
-
-	/**
-	 *  @private
-	 *  Storage variable for the original dataProvider
-	 */
-	private var _rootModel : ICollectionView;
-
-	/**
-	 *  @private
-	 *  Storage variable for the displayed dataProvider
-	 */
-	private var _displayedModel : ArrayCollection = new ArrayCollection();
-
-	/**
-	 * @private
-	 * The last sort that was set by clicking on the column headers.
-	 */
-	private var lastSort:Sort;
-
-	public function TreeGrid()
-	{
-		super();
-
-		setStyle("indentation", 18);
-
-		doubleClickEnabled = true;
-
-		addEventListener( KeyboardEvent.KEY_UP, keyboardHandler );
-
-		addEventListener(DataGridEvent.HEADER_RELEASE,
-			headerReleaseHandler,
-			false, 999);
-
-		addEventListener(ListEvent.ITEM_DOUBLE_CLICK, doubleClickHandler);
-	}
-
-	private function doubleClickHandler(event:ListEvent):void {
-		if(isItemOpen(event.itemRenderer.data)) {
-			closeItemAt(event.rowIndex, event.itemRenderer.data);
-		}
-		else {
-			openItemAt(event.rowIndex, event.itemRenderer.data);
-		}
-	}
-
-	/**
-	 * We want to prevent the defeault behavior, which would be the sort functionality
-	 * of the DataGrid class. The default sort behavior will not take the hierarchical
-	 * nature of the data into account and will make the rows lose their hierarchy.
-	 */
-	private function headerReleaseHandler(event:DataGridEvent):void {
-		event.preventDefault();
-		sortByColumn(event.columnIndex);
-	}
-
-	/**
-	 * This is essentailly the same sortByColumn function that is in DataGrid, but
-	 * modified only slightly. The main difference is the call to hierarchicalSort
-	 * at the end, which will sort the dataProvider and all the child items hierarchically.
-	 */
-	private function sortByColumn(index:int):void
-	{
-		var c:DataGridColumn = columns[index];
-		var desc:Boolean = c.sortDescending;
-
-		// do the sort if we're allowed to
-		if (c.sortable)
-		{
-			var s:Sort = lastSort;
-			var f:SortField;
-			if (s)
-			{
-				s.compareFunction = null;
-				// analyze the current sort to see what we've been given
-				var sf:Array = s.fields;
-				if (sf)
-				{
-					for (var i:int = 0; i < sf.length; i++)
-					{
-
-						if (sf[i].name == c.dataField)
-						{
-							// we're part of the current sort
-							f = sf[i]
-							// flip the logic so desc is new desired order
-							desc = !f.descending;
-							break;
-						}
-					}
-				}
-			}
-			else
-				s = new Sort;
-
-			if (!f) {
-				f = new SortField(c.dataField);
-			}
-
-			c.sortDescending = desc;
-
-			// if you have a labelFunction you must supply a sortCompareFunction
-			f.name = c.dataField;
-			if (c.sortCompareFunction != null)
-			{
-				f.compareFunction = c.sortCompareFunction;
-			}
-			else
-			{
-				f.compareFunction = null;
-			}
-			f.descending = desc;
-			s.fields = [f];
-
-			lastSort = s;
-		}
-
-		hierarchicalSort(_rootModel, s);
-	}
-
-	/**
-	 * Performs a sort of the ICollectionView and then gets all the children of
-	 * the node (if there are any) and performs the same sort on the children recursively.
-	 */
-	private function hierarchicalSort(items:ICollectionView, sort:Sort):void {
-		items.sort = sort;
-		items.refresh();
-
-		var n:int = items.length;
-		for(var i:int=0; i<n; i++) {
-			var item:Object = items[i];
-
-			var children:ICollectionView = _dataDescriptor.getChildren(item);
-
-			if(children) {
-				hierarchicalSort(children, sort);
-			}
-		}
-	}
-
-	public function dispatchTreeEvent(type:String,
-										   listData:TreeGridListData,
-										   renderer:IListItemRenderer,
-										   trigger:Event = null,
-										   opening:Boolean = true,
-										   dispatch:Boolean = true) : void
-	{
-		if( opening )
-		{
-			openItemAt( getItemIndex( listData.item ), listData.item );//listData.rowIndex - 1
-		}
-		else
-		{
-			closeItemAt( getItemIndex( listData.item ), listData.item ); //listData.rowIndex - 1
-		}
-	}
-
-	//--------------------------------------------------------------------------
-	//
-	//  DataProvider
-	//
-	//--------------------------------------------------------------------------
-
-	/**
-	 *  @private
-	 */
-	private var dataProviderChanged : Boolean = false;
-
-	/**
-	 * The TreeGrid can take a number of different kinds of data providers, such as collections,
-	 * xml, string, etc. These dataproviders all get converted to some form of collection class
-	 * in the setter for dataProvider. This means we may lose the actual reference to the dataProvider
-	 * object that the user passed in. So we store a reference to this object so we know if the user
-	 * is setting a completely new dataProvider or just updating the old dataProvider that was
-	 * previously set.
-	 */
-	private var _dataProviderAsSet : Object;
-
-	[Inspectable(category="Data", defaultValue="undefined")]
-	override public function set dataProvider( value : Object ) : void
-	{
-		if (_rootModel)
-			_rootModel.removeEventListener(
-							CollectionEvent.COLLECTION_CHANGE,
-							collectionChangeHandler);
-
-		if (_dataProviderAsSet != null && UIDUtil.getUID(value) == UIDUtil.getUID(_dataProviderAsSet)){
-			openItemsChanged = true;
-		}else{
-			_dataProviderAsSet = value;
-		}
-
-		// handle strings and xml
-		if (typeof(value)=="string")
-			value = new XML(value);
-		else if (value is XMLNode)
-			value = new XML(XMLNode(value).toString());
-		else if (value is XMLList)
-			value = new XMLListCollection(value as XMLList);
-
-		if (value is XML)
-		{
-			_hasRoot = true;
-			var xl:XMLList = new XMLList();
-			xl += value;
-			_rootModel = new XMLListCollection(xl);
-		}
-		//if already a collection dont make new one
-		else if (value is ICollectionView)
-		{
-			_rootModel = ICollectionView(value);
-		}
-		else if (value is Array)
-		{
-			_rootModel = new ArrayCollection(value as Array);
-		}
-		//all other types get wrapped in an ArrayCollection
-		else if (value is Object)
-		{
-			_hasRoot = true;
-			// convert to an array containing this one item
-			var tmp:Array = [];
-			   tmp.push(value);
-			_rootModel = new ArrayCollection(tmp);
-		  }
-		  else
-		  {
-			  _rootModel = new ArrayCollection();
-		  }
-
-		_rootModel.addEventListener(CollectionEvent.COLLECTION_CHANGE, rootModelChangeHandler);
-		//flag for processing in commitProps
-		dataProviderChanged = true;
-		invalidateProperties();
-	}
-
-	protected function rootModelChangeHandler(event:CollectionEvent):void {
-		dataProviderChanged = true;
-		openItemsChanged = true;
-		invalidateProperties();
-	}
-
-
-	override public function get dataProvider() : Object
-	{
-		return _rootModel;
-	}
-
-
-	//--------------------------------------------------------------------------
-	// dataDescriptor
-	//--------------------------------------------------------------------------
-
-	/**
-	 *  @private
-	 */
-	private var _dataDescriptor : ITreeDataDescriptor =
-		new DefaultDataDescriptor();
-
-	[Inspectable(category="Data")]
-	public function set dataDescriptor( value : ITreeDataDescriptor ) : void
-	{
-		_dataDescriptor = value;
-	}
-
-	public function get dataDescriptor() : ITreeDataDescriptor
-	{
-		return ITreeDataDescriptor( _dataDescriptor );
-	}
-
-	/**
-	 *  Sets the visibility of the root item.
-	 *
-	 *  If the dataProvider data has a root node, and this is set to
-	 *  false, the Tree control does not display the root item.
-	 *  Only the decendants of the root item are displayed.
-	 *
-	 *  This flag has no effect on non-rooted dataProviders, such as List and Array.
-	 *
-	 *  @default true
-	 *  @see #hasRoot
-	 */
-	public function get showRoot() : Boolean
-	{
-		return _showRoot;
-	}
-
-	/**
-	 *  @private
-	 */
-	public function set showRoot( value : Boolean ) : void
-	{
-		if ( _showRoot != value )
-		{
-			_showRoot = value;
-			showRootChanged = true;
-			invalidateProperties();
-		}
-	}
-
-	/**
-	 *  Indicates that the current dataProvider has a root item; for example,
-	 *  a single top node in a hierarchical structure. XML and Object
-	 *  are examples of types that have a root. Lists and arrays do not.
-	 *
-	 *  @see #showRoot
-	 */
-	public function get hasRoot() : Boolean
-	{
-		return _hasRoot;
-	}
-
-	private function keyboardHandler( event : KeyboardEvent ) : void {
-		switch( event.keyCode ) {
-			case Keyboard.LEFT:
-				expandSelectedNode();
-				event.preventDefault();
-				break;
-			case Keyboard.RIGHT:
-				closeSelectedNode();
-				event.preventDefault();
-				break;
-		}
-	}
-
-	private function expandSelectedNode():void {
-		if( _dataDescriptor.hasChildren( selectedItem ) && isItemOpen( selectedItem ) ) {
-			closeItemAt( selectedIndex, selectedItem );
-		}
-	}
-
-	private function closeSelectedNode():void {
-		if( _dataDescriptor.hasChildren( selectedItem ) && !isItemOpen( selectedItem ) ) {
-			openItemAt( selectedIndex, selectedItem );
-		}
-	}
-
-	override protected function commitProperties() : void
-	{
-		if ( showRootChanged )
-		{
-			if ( !_hasRoot )
-				showRootChanged = false;
-		}
-
-		if ( dataProviderChanged || showRootChanged )
-		{
-			var tmpCollection : ICollectionView;
-			var row : Object;
-
-			//we always reset the displayed rows on a dataprovider assignment or when the showRoot property change
-			_displayedModel = new ArrayCollection();
-
-			//reset flags
-			dataProviderChanged = false;
-			showRootChanged = false;
-
-			//we always reset the open and selected items on a dataprovider assignment
-			if ( !openItemsChanged )
-				  _openItems = {};
-
-			// are we swallowing the root?
-			if ( _rootModel && !_showRoot && _hasRoot )
-			{
-				var rootItem : * = _rootModel.createCursor().current;
-				if ( rootItem != null &&
-					 _dataDescriptor.isBranch( rootItem, _rootModel ) &&
-					 _dataDescriptor.hasChildren( rootItem, _rootModel ))
-				{
-					// then get rootItem children
-					tmpCollection = getChildren( rootItem, _rootModel );
-
-					for each( row in tmpCollection )
-					{
-						_displayedModel.addItem( row );
-					}
-				}
-			}
-			else
-			{
-				if( _hasRoot )
-				{
-					if( _rootModel != null && _rootModel.length > 0 )
-					{
-						_displayedModel.addItem( _rootModel[0] );
-					}
-				}
-				else
-				{
-					for each( row in _rootModel )
-					{
-						_displayedModel.addItem( row );
-					}
-				}
-			}
-
-			/* Before calling super.dataProvider we want to store the vertical and horizontal
-			 * scroll positions, as well as the list of selected items. After we set super.dataProvider
-			 * we need to always rest the selcted items, and if the open items have changed then we
-			 * need to reset the scroll positions.
-			 */
-			var vScrollPos:int = verticalScrollPosition;
-			var hScrollPos:int = horizontalScrollPosition;
-			var savedSelection : Array = selectedItems;
-
-			super.dataProvider = _displayedModel;
-
-		 //TODO: maybe we can use HierarchicalCollectionView?
-
-			/*// at this point _rootModel may be null so we dont need to continue
-			if ( _rootModel )
-			{
-				//wrap userdata in a TreeCollection and pass that collection to the List
-				super.dataProvider = wrappedCollection = new HierarchicalCollectionView(
-															tmpCollection != null ? tmpCollection : _rootModel,
-														   _dataDescriptor,
-														   _openItems);
-
-
-				   // not really a default handler, but we need to be later than the wrapper
-				wrappedCollection.addEventListener(CollectionEvent.COLLECTION_CHANGE,
-										  collectionChangeHandler,
-										  false,
-										  EventPriority.DEFAULT_HANDLER, true);
-			}
-			else
-			{
-				super.dataProvider = null;
-			}*/
-		 }
-
-		if ( openItemsChanged )
-		{
-			verticalScrollPosition = vScrollPos;
-			horizontalScrollPosition = hScrollPos;
-
-
-			for each(var item:* in openItems){
-				// only expand an item iff it's a direct child from the root.  openItemAt is recursive so don't worry about those here.
-				/*
-				if( _showRoot && _rootModel.contains( item )) {
-					var i : int = getItemIndex(item);
-					if( i >= 0 && i < collection.length ) {
-						openItemAt(i,item);
-					}
-				}
-				else if( !_showRoot) {
-					for(var j:int=0; j<_rootModel.length; j++) {
-						var rootChild:Object = _rootModel[j];
-						var children:ICollectionView = dataDescriptor.getChildren(rootChild, _rootModel);
-
-						if(children.contains(item)) {
-							var i : int = getItemIndex(item);
-							if( i >= 0 && i < collection.length ) {
-								openItemAt(i,item);
-							}
-						}
-					}
-				}
-				*/
-
-				var rootNodes:Object;
-				if(_showRoot || _hasRoot == false) {
-					rootNodes = _rootModel;
-				}
-				else {
-					rootNodes = [_rootModel[0]];
-				}
-
-				for(var i:int=0; i<rootNodes.length; i++) {
-					var rootChild:Object = rootNodes[i];
-					var itemIndex:int;
-
-					if(rootChild == item) {
-						itemIndex = getItemIndex(item);
-						if( itemIndex >= 0 && itemIndex < collection.length ) {
-							openItemAt(itemIndex,item);
-						}
-					}
-					else {
-						var children:ICollectionView = dataDescriptor.getChildren(rootChild, _rootModel);
-
-						if(children && children.contains(item)) {
-							itemIndex = getItemIndex(item);
-							if( itemIndex >= 0 && itemIndex < collection.length ) {
-								openItemAt(itemIndex,item);
-							}
-						}
-					}
-				}
-			}
-
-			openItemsChanged = false;
-			//setting open items resets the collection
-			var event : CollectionEvent =
-				new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
-			   event.kind = CollectionEventKind.RESET;
-			   collection.dispatchEvent(event);
-		}
-
-		super.selectedItems = savedSelection;
-
-		super.commitProperties();
-	}
-
-	override protected function makeListData(
-		data : Object,
-		uid : String,
-		rowNum : int,
-		columnNum : int,
-		column : DataGridColumn ) : BaseListData
-	{
-		var treeGridListData : TreeGridListData;
-
-		if ( data is DataGridColumn )
-		{
-			treeGridListData = new TreeGridListData(
-				(column.headerText != null) ? column.headerText : column.dataField,
-				column.dataField,
-				columnNum,
-				uid,
-				this,
-				rowNum);
-		}
-		else
-		{
-			treeGridListData = new TreeGridListData(
-				column.itemToLabel(data),
-				column.dataField,
-				columnNum, uid,
-				this,
-				rowNum);
-
-			initListData( data, treeGridListData );
-		}
-
-		return treeGridListData;
-	}
-
-	protected function initListData( item : Object, treeListData : TreeGridListData ) : void
-	{
-		if (item == null)
-			return;
-
-		var open:Boolean = isItemOpen(item);
-		var branch:Boolean = isBranch(item);
-		var uid:String = itemToUID(item);
-
-		// this is hidden by non-branches but kept so we know how wide it is so things align
-		treeListData.disclosureIcon = getStyle(open ? "disclosureOpenIcon" :
-													  "disclosureClosedIcon");
-		if(treeListData.disclosureIcon == null) {
-			treeListData.disclosureIcon = open ? defaultDisclosureOpenClass : defaultDisclosureClosedClass;
-		}
-
-		treeListData.open = open;
-		treeListData.hasChildren = branch;
-		treeListData.depth = getItemDepth( item, treeListData.rowIndex );
-		treeListData.indent = (treeListData.depth - ( _showRoot ? 1 : 2 ) ) * getStyle("indentation");
-		treeListData.indentationGap = getStyle("indentation");
-		treeListData.item = item;
-		treeListData.icon = itemToIcon( item );
-
-		treeListData.trunk = getStyle("verticalTrunks");
-		if( treeListData.trunk )
-		{
-			treeListData.trunkOffsetTop = getStyle("paddingTop");
-			treeListData.trunkOffsetBottom = getStyle("paddingBottom");
-			treeListData.hasSibling = !isLastItem( treeListData );
-
-			var trunkColor:Object = getStyle("trunkColor");
-			treeListData.trunkColor = trunkColor ? uint(trunkColor) : 0xffffff;
-		}
-	}
-
-	private function getChildren( item : Object, view : Object) : ICollectionView
-	{
-		//get the collection of children
-		var children : ICollectionView = _dataDescriptor.getChildren( item, view );
-
-		return children;
-	}
-
-	/**
-	* This method find if the current node is the last displayed sibling
-	*
-	* Used to draw the vertical trunk lines,
-	* if it is the last child then the vertical trunk line should stop in the middle of the row
-	**/
-	protected function isLastItem( listData : TreeGridListData ) : Boolean
-	{
-		//TODO: find a way to optimize this method, it's SLOOOWWWW maybe by using HierarchicalCollectionView? ...
-
-		/*
-		var rowIndex : int = getItemIndex( listData.item );
-
-		var data : Object = IList( dataProvider ).getItemAt( rowIndex );
-
-		if( IList( dataProvider ).length > rowIndex + 1 )
-		{
-			for(var i:int = rowIndex + 1; i < IList( dataProvider ).length; i++)
-			{
-				var nextData : Object = IList( dataProvider ).getItemAt( i );
-
-				var nextDataDepth : int = getItemDepth( nextData, i );
-
-				if( nextDataDepth == listData.depth )
-					return false;
-			}
-		}
-		*/
-
-		return false;
-	}
-
-	protected function getItemDepth( item : Object, offset : int ) : int
-	{
-		var depth : int;
-
-		//if the dataprovider have a root, we begin from the root.
-		if( hasRoot )
-		{
-			depth = searchForCurrentDepth( dataProvider[0], item );
-		}
-		//If the dataprovider don't have a root, we need to parse all items from the first level.
-		else
-		{
-			var i : int = 0;
-			do
-			{
-				depth = searchForCurrentDepth( dataProvider[i++], item );
-			}
-			while( depth == -1)
-		}
-
-		if( depth == -1 )
-			throw new Error("item not found");
-
-		return depth;
-
-	}
-
-	/**
-	 *
-	 */
-	private function searchForCurrentDepth(
-		value : Object,
-		item : Object,
-		depth : int = 1 ) : int
-	{
-		if( value == item )
-			return depth;
-
-		if( value == null || _dataDescriptor.getChildren( value ) == null )
-			return -1;
-
-		depth++;
-		for( var i : int = 0; i < _dataDescriptor.getChildren( value ).length; i++ )
-		{
-			var result : int =
-				searchForCurrentDepth( _dataDescriptor.getChildren( value )[i], item, depth );
-
-			if( result != -1)
-				return result;
-		}
-
-		return -1;
-	}
-
-	/**
-	 *  @private
-	 */
-	private function getItemIndex(item:Object):int
-	{
-		var cursor:IViewCursor = collection.createCursor();
-		var i:int = 0;
-
-		do
-		{
-			if (cursor.current === item)
-				break;
-			i++;
-		}
-		while ( cursor.moveNext() );
-
-		return i;
-	}
-
-	//--------------------------------------------------------------------------
-	//
-	//  public methods
-	//
-	//--------------------------------------------------------------------------
-
-	/**
-	 *  @private
-	 */
-	private var openItemsChanged : Boolean = false;
-
-	/**
-	 *  The items that have been opened or set opened.
-	 *
-	 *  @default null
-	 */
-	public function get openItems():Object
-	{
-		var openItemsArray:Array = [];
-		for each(var item:* in _openItems)
-		{
-			openItemsArray.push(item);
-		}
-		return openItemsArray;
-	}
-
-	/**
-	 *  @private
-	 */
-	public function set openItems(value:Object):void
-	{
-		if (value != null)
-		{
-			for each (var item:* in value)
-			{
-				_openItems[itemToUID(item)] = item;
-			}
-
-			openItemsChanged = true;
-			invalidateProperties();
-		}
-	}
-
-	/**
-	 *
-	 */
-	public function isBranch( item : Object ) : Boolean
-	{
-		if (item != null)
-			return _dataDescriptor.isBranch( item, iterator.view );
-
-		return false;
-	}
-
-	/**
-	 *
-	 */
-	public function isItemOpen( item : Object) : Boolean
-	{
-		var uid : String = itemToUID( item );
-
-		return _openItems[ uid ] != null;
-	}
-
-	/**
-	 *  @private
-	 */
-	override public function itemToIcon( item : Object ) : Class
-	{
-		if ( item == null )
-		{
-			return null;
-		}
-
-		var icon : *;
-		var open : Boolean = isItemOpen( item );
-		var branch : Boolean = isBranch( item );
-		var uid : String = itemToUID( item );
-
-		//first lets check the component
-		var iconClass : Class =
-				itemIcons && itemIcons[uid] ?
-				itemIcons[uid][open ? "iconID2" : "iconID"] :
-				null;
-
-		if ( iconClass )
-		{
-			return iconClass;
-		}
-		else if ( iconFunction != null )
-		{
-			return iconFunction( item );
-		}
-		else if ( branch )
-		{
-			return getStyle(open ? "folderOpenIcon" : "folderClosedIcon");
-		}
-		else
-		//let's check the item itself
-		{
-			if ( item is XML )
-			{
-				try
-				{
-					if (item[ iconField ].length() != 0)
-						icon = String( item[iconField] );
-				}
-				   catch( e : Error )
-				   {
-				   }
-			}
-			else if ( item is Object )
-			{
-				try
-				{
-					if ( iconField && item[iconField] )
-						icon = item[ iconField ];
-					else if ( item.icon )
-						icon = item.icon;
-				}
-				catch ( e : Error )
-				{
-				}
-			}
-		}
-
-		//set default leaf icon if nothing else was found
-		if ( icon == null )
-			icon = getStyle("defaultLeafIcon");
-
-		//convert to the correct type and class
-		if ( icon is Class )
-		{
-			return icon;
-		}
-		else if ( icon is String )
-		{
-			iconClass = Class( systemManager.getDefinitionByName(String(icon)) );
-			if ( iconClass )
-				return iconClass;
-
-			return document[icon];
-		}
-		else
-		{
-			return Class(icon);
-		}
-
-	}
-
-	/**
-	 *  Sets the associated icon for the item.  Calling this method overrides the
-	 *  iconField and iconFunction properties for
-	 *  this item if it is a leaf item. Branch items don't use the
-	 *  iconField and iconFunction properties.
-	 *  They use the folderOpenIcon and folderClosedIcon properties.
-	 *
-	 *  @param item Item to affect.
-	 *  @param iconID Linkage ID for the closed (or leaf) icon.
-	 *  @param iconID2 Linkage ID for the open icon.
-	 *
-	 *  @tiptext Sets the icons for the specified item
-	 *  @helpid 3201
-	 */
-	public function setItemIcon(item:Object, iconID:Class, iconID2:Class):void
-	{
-		if ( !itemIcons )
-			itemIcons = {};
-
-		if ( !iconID2 )
-			iconID2 = iconID;
-
-		itemIcons[ itemToUID(item) ] = { iconID: iconID, iconID2: iconID2 };
-
-		itemsSizeChanged = true;
-		invalidateDisplayList();
-	}
-
-	/**
-	 *
-	 */
-	public function closeAllItems() : void
-	{
-		for( var i : int = 0; i < ICollectionView( _displayedModel ).length; i++ )
-		{
-			this.closeItemAt( i );
-		}
-	}
-
-	/**
-	 *
-	 */
-	public function closeItemAt( rowNum : Number, item : Object = null, closeItem : Boolean = true ) : void
-	{
-		if( item == null )
-			item = ListCollectionView( _displayedModel ).getItemAt( rowNum );
-
-		if( closeItem )
-		{
-			var uid : String = itemToUID( item );
-			delete _openItems[ uid ];
-		}
-
-		if( _dataDescriptor.getChildren( item ) )
-		{
-			// recursively remove the rows that were added for child records
-			// but don't remove item from _openItems[] to keep opened items.
-			for( var i : int = 0; i < _dataDescriptor.getChildren( item ).length; i++ )
-			{
-				if( isItemOpen( _dataDescriptor.getChildren( item )[ i ] ) )
-				{
-				closeItemAt( rowNum, _dataDescriptor.getChildren( item )[ i ], false );
-				}
-
-				ListCollectionView( _displayedModel ).removeItemAt( rowNum + 1 );
-			}
-		 }
-	}
-
-	/**
-	 * @return the number of rows added to the display model
-	 */
-	public function openItemAt( rowNum : Number, item : Object = null ) : Number
-	{
-		//if there was no item passed in then retrieve it via row number
-		if ( item == null )
-			item = ListCollectionView( _displayedModel ).getItemAt( rowNum );
-
-		//if the item is not already open
-		//if (!isItemOpen(item))
-		//{
-			//add the item to the list of open items
-			var uid : String = itemToUID( item );
-			_openItems[ uid ] = item;
-
-			var savedSelection : Array = this.selectedItems;
-			this.clearSelected();
-
-			var children:ICollectionView = _dataDescriptor.getChildren( item );
-
-			//if there are children then go and open them up, otherwise skip to the bottom and return 0
-			if ( children )
-			{
-				// add the rows for the children at this level
-				for ( var i : int = 0; i < children.length; i++ )
-				{
-					var child:Object = children[i];
-					if(ListCollectionView( _displayedModel ).contains(child) == false) {
-						ListCollectionView( _displayedModel ).addItemAt( child, rowNum + i + 1 );
-					}
-				}
-
-				var offset:Number = 0;
-
-				for ( i = 0; i < children.length; i++ )
-				{
-					var vChild:Object = children[ i ];
-
-					if ( isItemOpen( vChild ) )
-					{
-						offset += openItemAt( rowNum + i + 1 + offset, vChild );
-					}
-				}
-			}
-
-			super.selectedItems = savedSelection;
-
-			//return the number of children that were opened
-			return _dataDescriptor.getChildren( item ).length + offset;
-		//}
-		//else {
-			//if the item was already open then return 0
-		//	return 0;
-		//}
-	}
-
-
-
-} // end class
+  import flash.events.Event;
+  import flash.events.KeyboardEvent;
+  import flash.ui.Keyboard;
+  import flash.xml.XMLNode;
+
+  import flexlib.controls.treeGridClasses.TreeGridListData;
+
+  import mx.collections.ArrayCollection;
+  import mx.collections.ICollectionView;
+  import mx.collections.IViewCursor;
+  import mx.collections.ListCollectionView;
+  import mx.collections.Sort;
+  import mx.collections.SortField;
+  import mx.collections.XMLListCollection;
+  import mx.controls.DataGrid;
+  import mx.controls.dataGridClasses.DataGridColumn;
+  import mx.controls.listClasses.BaseListData;
+  import mx.controls.listClasses.IListItemRenderer;
+  import mx.controls.treeClasses.DefaultDataDescriptor;
+  import mx.controls.treeClasses.ITreeDataDescriptor2;
+  import mx.events.CollectionEvent;
+  import mx.events.CollectionEventKind;
+  import mx.events.DataGridEvent;
+  import mx.utils.UIDUtil;
+  import mx.controls.treeClasses.ITreeDataDescriptor;
+  import flash.events.MouseEvent;
+  import mx.events.ListEvent;
+
+
+  [Style(name="disclosureOpenIcon", type="Class", format="EmbeddedFile", inherit="no")]
+
+  [Style(name="disclosureClosedIcon", type="Class", format="EmbeddedFile", inherit="no")]
+
+  [Style(name="folderOpenIcon", type="Class", format="EmbeddedFile", inherit="no")]
+
+  [Style(name="folderClosedIcon", type="Class", format="EmbeddedFile", inherit="no")]
+
+  [Style(name="defaultLeafIcon", type="Class", format="EmbeddedFile", inherit="no")]
+
+  [Style(name="indentation", type="Number", inherit="no")]
+
+  [Style(name="verticalTrunks", type="String", enumeration="none,normal,dotted", inherit="no")]
+
+  [Style(name="trunkColor", type="uint", format="Color", inherit="yes")]
+
+  /**
+   *
+   */
+  public class TreeGrid extends DataGrid
+  {
+
+    [Embed(source='../assets/defaultTreeAssets.swf#TreeDisclosureClosed')]
+    private var defaultDisclosureClosedClass:Class;
+
+    [Embed(source='../assets/defaultTreeAssets.swf#TreeDisclosureOpen')]
+    private var defaultDisclosureOpenClass:Class;
+
+    /**
+     *  @private
+     *  Used to hold a list of items that are opened or set opened.
+     */
+    private var _openItems:Object = {};
+
+
+    /**
+     *  An object that specifies the icons for the items.
+     *  Each entry in the object has a field name that is the item UID
+     *  and a value that is an an object with the following format:
+     *

+     *  {iconID: Class, iconID2: Class}
+     *

+     *  The iconID field value is the class of the icon for
+     *  a closed or leaf item and the iconID2 is the class
+     *  of the icon for an open item.
+     *
+     *
This property is intended to allow initialization of item icons.
+     *  Changes to this array after initialization are not detected
+     *  automatically.
+     *  Use the setItemIcon() method to change icons dynamically.

+     *
+     *  @see #setItemIcon()
+     *  @default undefined
+     */
+    public var itemIcons:Object;
+
+    /**
+     *  @private
+     *  Storage variable for showRoot flag.
+     */
+    private var _showRoot:Boolean = true;
+
+    /**
+     *  @private
+     *  Storage variable for changes to showRoot.
+     */
+    private var showRootChanged:Boolean = false;
+
+    /**
+     *  @private
+     *  Flag to indicate if the model has a root
+     */
+    private var _hasRoot:Boolean = false;
+
+    /**
+     *  @private
+     *  Storage variable for the original dataProvider
+     */
+    private var _rootModel:ICollectionView;
+
+    /**
+     *  @private
+     *  Storage variable for the displayed dataProvider
+     */
+    private var _displayedModel:ArrayCollection = new ArrayCollection();
+
+    /**
+     * @private
+     * The last sort that was set by clicking on the column headers.
+     */
+    private var lastSort:Sort;
+
+    public function TreeGrid()
+    {
+      super();
+
+      setStyle("indentation", 18);
+
+      doubleClickEnabled = true;
+
+      addEventListener(KeyboardEvent.KEY_UP, keyboardHandler);
+
+      addEventListener(DataGridEvent.HEADER_RELEASE,
+                       headerReleaseHandler,
+                       false, 999);
+
+      addEventListener(ListEvent.ITEM_DOUBLE_CLICK, doubleClickHandler);
+    }
+
+    private function doubleClickHandler(event:ListEvent):void
+    {
+      if (isItemOpen(event.itemRenderer.data))
+      {
+        closeItemAt(event.rowIndex, event.itemRenderer.data);
+      }
+      else
+      {
+        openItemAt(event.rowIndex, event.itemRenderer.data);
+      }
+    }
+
+    /**
+     * We want to prevent the defeault behavior, which would be the sort functionality
+     * of the DataGrid class. The default sort behavior will not take the hierarchical
+     * nature of the data into account and will make the rows lose their hierarchy.
+     */
+    private function headerReleaseHandler(event:DataGridEvent):void
+    {
+      event.preventDefault();
+      sortByColumn(event.columnIndex);
+    }
+
+    /**
+     * This is essentailly the same sortByColumn function that is in DataGrid, but
+     * modified only slightly. The main difference is the call to hierarchicalSort
+     * at the end, which will sort the dataProvider and all the child items hierarchically.
+     */
+    private function sortByColumn(index:int):void
+    {
+      var c:DataGridColumn = columns[index];
+      var desc:Boolean = c.sortDescending;
+
+      // do the sort if we're allowed to
+      if (c.sortable)
+      {
+        var s:Sort = lastSort;
+        var f:SortField;
+        if (s)
+        {
+          s.compareFunction = null;
+          // analyze the current sort to see what we've been given
+          var sf:Array = s.fields;
+          if (sf)
+          {
+            for (var i:int = 0; i < sf.length; i++)
+            {
+
+              if (sf[i].name == c.dataField)
+              {
+                // we're part of the current sort
+                f = sf[i]
+                // flip the logic so desc is new desired order
+                desc = !f.descending;
+                break;
+              }
+            }
+          }
+        }
+        else
+          s = new Sort;
+
+        if (!f)
+        {
+          f = new SortField(c.dataField);
+        }
+
+        c.sortDescending = desc;
+
+        // if you have a labelFunction you must supply a sortCompareFunction
+        f.name = c.dataField;
+        if (c.sortCompareFunction != null)
+        {
+          f.compareFunction = c.sortCompareFunction;
+        }
+        else
+        {
+          f.compareFunction = null;
+        }
+        f.descending = desc;
+        s.fields = [f];
+
+        lastSort = s;
+      }
+
+      hierarchicalSort(_rootModel, s);
+    }
+
+    /**
+     * Performs a sort of the ICollectionView and then gets all the children of
+     * the node (if there are any) and performs the same sort on the children recursively.
+     */
+    private function hierarchicalSort(items:ICollectionView, sort:Sort):void
+    {
+      items.sort = sort;
+      items.refresh();
+
+      var n:int = items.length;
+      for (var i:int = 0; i < n; i++)
+      {
+        var item:Object = items[i];
+
+        var children:ICollectionView = _dataDescriptor.getChildren(item);
+
+        if (children)
+        {
+          hierarchicalSort(children, sort);
+        }
+      }
+    }
+
+    public function dispatchTreeEvent(type:String,
+                                      listData:TreeGridListData,
+                                      renderer:IListItemRenderer,
+                                      trigger:Event=null,
+                                      opening:Boolean=true,
+                                      dispatch:Boolean=true):void
+    {
+      if (opening)
+      {
+        openItemAt(getItemIndex(listData.item), listData.item); //listData.rowIndex - 1
+      }
+      else
+      {
+        closeItemAt(getItemIndex(listData.item), listData.item); //listData.rowIndex - 1
+      }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  DataProvider
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private var dataProviderChanged:Boolean = false;
+
+    /**
+     * The TreeGrid can take a number of different kinds of data providers, such as collections,
+     * xml, string, etc. These dataproviders all get converted to some form of collection class
+     * in the setter for dataProvider. This means we may lose the actual reference to the dataProvider
+     * object that the user passed in. So we store a reference to this object so we know if the user
+     * is setting a completely new dataProvider or just updating the old dataProvider that was
+     * previously set.
+     */
+    private var _dataProviderAsSet:Object;
+
+    [Inspectable(category="Data", defaultValue="undefined")]
+    override public function set dataProvider(value:Object):void
+    {
+      if (_rootModel)
+        _rootModel.removeEventListener(
+          CollectionEvent.COLLECTION_CHANGE,
+          collectionChangeHandler);
+
+      if (_dataProviderAsSet != null && UIDUtil.getUID(value) == UIDUtil.getUID(_dataProviderAsSet))
+      {
+        openItemsChanged = true;
+      }
+      else
+      {
+        _dataProviderAsSet = value;
+      }
+
+      // handle strings and xml
+      if (typeof(value) == "string")
+        value = new XML(value);
+      else if (value is XMLNode)
+        value = new XML(XMLNode(value).toString());
+      else if (value is XMLList)
+        value = new XMLListCollection(value as XMLList);
+
+      if (value is XML)
+      {
+        _hasRoot = true;
+        var xl:XMLList = new XMLList();
+        xl += value;
+        _rootModel = new XMLListCollection(xl);
+      }
+      //if already a collection dont make new one
+      else if (value is ICollectionView)
+      {
+        _rootModel = ICollectionView(value);
+      }
+      else if (value is Array)
+      {
+        _rootModel = new ArrayCollection(value as Array);
+      }
+      //all other types get wrapped in an ArrayCollection
+      else if (value is Object)
+      {
+        _hasRoot = true;
+        // convert to an array containing this one item
+        var tmp:Array = [];
+        tmp.push(value);
+        _rootModel = new ArrayCollection(tmp);
+      }
+      else
+      {
+        _rootModel = new ArrayCollection();
+      }
+
+      _rootModel.addEventListener(CollectionEvent.COLLECTION_CHANGE, rootModelChangeHandler);
+      //flag for processing in commitProps
+      dataProviderChanged = true;
+      invalidateProperties();
+    }
+
+    protected function rootModelChangeHandler(event:CollectionEvent):void
+    {
+      dataProviderChanged = true;
+      openItemsChanged = true;
+      invalidateProperties();
+    }
+
+
+    override public function get dataProvider():Object
+    {
+      return _rootModel;
+    }
+
+
+    //--------------------------------------------------------------------------
+    // dataDescriptor
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private var _dataDescriptor:ITreeDataDescriptor =
+      new DefaultDataDescriptor();
+
+    [Inspectable(category="Data")]
+    public function set dataDescriptor(value:ITreeDataDescriptor):void
+    {
+      _dataDescriptor = value;
+    }
+
+    public function get dataDescriptor():ITreeDataDescriptor
+    {
+      return ITreeDataDescriptor(_dataDescriptor);
+    }
+
+    /**
+     *  Sets the visibility of the root item.
+     *
+     *  If the dataProvider data has a root node, and this is set to
+     *  false, the Tree control does not display the root item.
+     *  Only the decendants of the root item are displayed.
+     *
+     *  This flag has no effect on non-rooted dataProviders, such as List and Array.
+     *
+     *  @default true
+     *  @see #hasRoot
+     */
+    public function get showRoot():Boolean
+    {
+      return _showRoot;
+    }
+
+    /**
+     *  @private
+     */
+    public function set showRoot(value:Boolean):void
+    {
+      if (_showRoot != value)
+      {
+        _showRoot = value;
+        showRootChanged = true;
+        invalidateProperties();
+      }
+    }
+
+    /**
+     *  Indicates that the current dataProvider has a root item; for example,
+     *  a single top node in a hierarchical structure. XML and Object
+     *  are examples of types that have a root. Lists and arrays do not.
+     *
+     *  @see #showRoot
+     */
+    public function get hasRoot():Boolean
+    {
+      return _hasRoot;
+    }
+
+    private function keyboardHandler(event:KeyboardEvent):void
+    {
+      switch (event.keyCode)
+      {
+        case Keyboard.LEFT:
+          expandSelectedNode();
+          event.preventDefault();
+          break;
+        case Keyboard.RIGHT:
+          closeSelectedNode();
+          event.preventDefault();
+          break;
+      }
+    }
+
+    private function expandSelectedNode():void
+    {
+      if (_dataDescriptor.hasChildren(selectedItem) && isItemOpen(selectedItem))
+      {
+        closeItemAt(selectedIndex, selectedItem);
+      }
+    }
+
+    private function closeSelectedNode():void
+    {
+      if (_dataDescriptor.hasChildren(selectedItem) && !isItemOpen(selectedItem))
+      {
+        openItemAt(selectedIndex, selectedItem);
+      }
+    }
+
+    override protected function commitProperties():void
+    {
+      if (showRootChanged)
+      {
+        if (!_hasRoot)
+          showRootChanged = false;
+      }
+
+      if (dataProviderChanged || showRootChanged)
+      {
+        var tmpCollection:ICollectionView;
+        var row:Object;
+
+        //we always reset the displayed rows on a dataprovider assignment or when the showRoot property change
+        _displayedModel = new ArrayCollection();
+
+        //reset flags
+        dataProviderChanged = false;
+        showRootChanged = false;
+
+        //we always reset the open and selected items on a dataprovider assignment
+        if (!openItemsChanged)
+          _openItems = {};
+
+        // are we swallowing the root?
+        if (_rootModel && !_showRoot && _hasRoot)
+        {
+          var rootItem:* = _rootModel.createCursor().current;
+          if (rootItem != null &&
+            _dataDescriptor.isBranch(rootItem, _rootModel) &&
+            _dataDescriptor.hasChildren(rootItem, _rootModel))
+          {
+            // then get rootItem children
+            tmpCollection = getChildren(rootItem, _rootModel);
+
+            for each (row in tmpCollection)
+            {
+              _displayedModel.addItem(row);
+            }
+          }
+        }
+        else
+        {
+          if (_hasRoot)
+          {
+            if (_rootModel != null && _rootModel.length > 0)
+            {
+              _displayedModel.addItem(_rootModel[0]);
+            }
+          }
+          else
+          {
+            for each (row in _rootModel)
+            {
+              _displayedModel.addItem(row);
+            }
+          }
+        }
+
+        /* Before calling super.dataProvider we want to store the vertical and horizontal
+         * scroll positions, as well as the list of selected items. After we set super.dataProvider
+         * we need to always rest the selcted items, and if the open items have changed then we
+         * need to reset the scroll positions.
+         */
+        var vScrollPos:int = verticalScrollPosition;
+        var hScrollPos:int = horizontalScrollPosition;
+        var savedSelection:Array = selectedItems;
+
+        super.dataProvider = _displayedModel;
+
+          //TODO: maybe we can use HierarchicalCollectionView?
+
+        /*// at this point _rootModel may be null so we dont need to continue
+           if ( _rootModel )
+           {
+           //wrap userdata in a TreeCollection and pass that collection to the List
+           super.dataProvider = wrappedCollection = new HierarchicalCollectionView(
+           tmpCollection != null ? tmpCollection : _rootModel,
+           _dataDescriptor,
+           _openItems);
+
+
+           // not really a default handler, but we need to be later than the wrapper
+           wrappedCollection.addEventListener(CollectionEvent.COLLECTION_CHANGE,
+           collectionChangeHandler,
+           false,
+           EventPriority.DEFAULT_HANDLER, true);
+           }
+           else
+           {
+           super.dataProvider = null;
+         }*/
+      }
+
+      if (openItemsChanged)
+      {
+        verticalScrollPosition = vScrollPos;
+        horizontalScrollPosition = hScrollPos;
+
+
+        for each (var item:*in openItems)
+        {
+          // only expand an item iff it's a direct child from the root.  openItemAt is recursive so don't worry about those here.
+          /*
+             if( _showRoot && _rootModel.contains( item )) {
+             var i : int = getItemIndex(item);
+             if( i >= 0 && i < collection.length ) {
+             openItemAt(i,item);
+             }
+             }
+             else if( !_showRoot) {
+             for(var j:int=0; j<_rootModel.length; j++) {
+             var rootChild:Object = _rootModel[j];
+             var children:ICollectionView = dataDescriptor.getChildren(rootChild, _rootModel);
+
+             if(children.contains(item)) {
+             var i : int = getItemIndex(item);
+             if( i >= 0 && i < collection.length ) {
+             openItemAt(i,item);
+             }
+             }
+             }
+             }
+           */
+
+          var rootNodes:Object;
+          if (_showRoot || _hasRoot == false)
+          {
+            rootNodes = _rootModel;
+          }
+          else
+          {
+            rootNodes = [_rootModel[0]];
+          }
+
+          for (var i:int = 0; i < rootNodes.length; i++)
+          {
+            var rootChild:Object = rootNodes[i];
+            var itemIndex:int;
+
+            if (rootChild == item)
+            {
+              itemIndex = getItemIndex(item);
+              if (itemIndex >= 0 && itemIndex < collection.length)
+              {
+                openItemAt(itemIndex, item);
+              }
+            }
+            else
+            {
+              var children:ICollectionView = dataDescriptor.getChildren(rootChild, _rootModel);
+
+              if (children && children.contains(item))
+              {
+                itemIndex = getItemIndex(item);
+                if (itemIndex >= 0 && itemIndex < collection.length)
+                {
+                  openItemAt(itemIndex, item);
+                }
+              }
+            }
+          }
+        }
+
+        openItemsChanged = false;
+        //setting open items resets the collection
+        var event:CollectionEvent =
+          new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
+        event.kind = CollectionEventKind.RESET;
+        collection.dispatchEvent(event);
+      }
+
+      super.selectedItems = savedSelection;
+
+      super.commitProperties();
+    }
+
+    override protected function makeListData(
+      data:Object,
+      uid:String,
+      rowNum:int,
+      columnNum:int,
+      column:DataGridColumn):BaseListData
+    {
+      var treeGridListData:TreeGridListData;
+
+      if (data is DataGridColumn)
+      {
+        treeGridListData = new TreeGridListData(
+          (column.headerText != null) ? column.headerText : column.dataField,
+          column.dataField,
+          columnNum,
+          uid,
+          this,
+          rowNum);
+      }
+      else
+      {
+        treeGridListData = new TreeGridListData(
+          column.itemToLabel(data),
+          column.dataField,
+          columnNum, uid,
+          this,
+          rowNum);
+
+        initListData(data, treeGridListData);
+      }
+
+      return treeGridListData;
+    }
+
+    protected function initListData(item:Object, treeListData:TreeGridListData):void
+    {
+      if (item == null)
+        return;
+
+      var open:Boolean = isItemOpen(item);
+      var branch:Boolean = isBranch(item);
+      var uid:String = itemToUID(item);
+
+      // this is hidden by non-branches but kept so we know how wide it is so things align
+      treeListData.disclosureIcon = getStyle(open ? "disclosureOpenIcon" :
+                                             "disclosureClosedIcon");
+      if (treeListData.disclosureIcon == null)
+      {
+        treeListData.disclosureIcon = open ? defaultDisclosureOpenClass : defaultDisclosureClosedClass;
+      }
+
+      treeListData.open = open;
+      treeListData.hasChildren = branch;
+      treeListData.depth = getItemDepth(item, treeListData.rowIndex);
+      treeListData.indent = (treeListData.depth - (_showRoot ? 1 : 2)) * getStyle("indentation");
+      treeListData.indentationGap = getStyle("indentation");
+      treeListData.item = item;
+      treeListData.icon = itemToIcon(item);
+
+      treeListData.trunk = getStyle("verticalTrunks");
+      if (treeListData.trunk)
+      {
+        treeListData.trunkOffsetTop = getStyle("paddingTop");
+        treeListData.trunkOffsetBottom = getStyle("paddingBottom");
+        treeListData.hasSibling = !isLastItem(treeListData);
+
+        var trunkColor:Object = getStyle("trunkColor");
+        treeListData.trunkColor = trunkColor ? uint(trunkColor) : 0xffffff;
+      }
+    }
+
+    private function getChildren(item:Object, view:Object):ICollectionView
+    {
+      //get the collection of children
+      var children:ICollectionView = _dataDescriptor.getChildren(item, view);
+
+      return children;
+    }
+
+    /**
+     * This method find if the current node is the last displayed sibling
+     *
+     * Used to draw the vertical trunk lines,
+     * if it is the last child then the vertical trunk line should stop in the middle of the row
+     **/
+    protected function isLastItem(listData:TreeGridListData):Boolean
+    {
+      //TODO: find a way to optimize this method, it's SLOOOWWWW maybe by using HierarchicalCollectionView? ...
+
+      /*
+         var rowIndex : int = getItemIndex( listData.item );
+
+         var data : Object = IList( dataProvider ).getItemAt( rowIndex );
+
+         if( IList( dataProvider ).length > rowIndex + 1 )
+         {
+         for(var i:int = rowIndex + 1; i < IList( dataProvider ).length; i++)
+         {
+         var nextData : Object = IList( dataProvider ).getItemAt( i );
+
+         var nextDataDepth : int = getItemDepth( nextData, i );
+
+         if( nextDataDepth == listData.depth )
+         return false;
+         }
+         }
+       */
+
+      return false;
+    }
+
+    protected function getItemDepth(item:Object, offset:int):int
+    {
+      var depth:int;
+
+      //if the dataprovider have a root, we begin from the root.
+      if (hasRoot)
+      {
+        depth = searchForCurrentDepth(dataProvider[0], item);
+      }
+      //If the dataprovider don't have a root, we need to parse all items from the first level.
+      else
+      {
+        var i:int = 0;
+        do
+        {
+          depth = searchForCurrentDepth(dataProvider[i++], item);
+        } while (depth == -1)
+      }
+
+      if (depth == -1)
+        throw new Error("item not found");
+
+      return depth;
+
+    }
+
+    /**
+     *
+     */
+    private function searchForCurrentDepth(
+      value:Object,
+      item:Object,
+      depth:int=1):int
+    {
+      if (value == item)
+        return depth;
+
+      if (value == null || _dataDescriptor.getChildren(value) == null)
+        return -1;
+
+      depth++;
+      for (var i:int = 0; i < _dataDescriptor.getChildren(value).length; i++)
+      {
+        var result:int =
+          searchForCurrentDepth(_dataDescriptor.getChildren(value)[i], item, depth);
+
+        if (result != -1)
+          return result;
+      }
+
+      return -1;
+    }
+
+    /**
+     *  @private
+     */
+    private function getItemIndex(item:Object):int
+    {
+      var cursor:IViewCursor = collection.createCursor();
+      var i:int = 0;
+
+      do
+      {
+        if (cursor.current === item)
+          break;
+        i++;
+      } while (cursor.moveNext());
+
+      return i;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  public methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    private var openItemsChanged:Boolean = false;
+
+    /**
+     *  The items that have been opened or set opened.
+     *
+     *  @default null
+     */
+    public function get openItems():Object
+    {
+      var openItemsArray:Array = [];
+      for each (var item:*in _openItems)
+      {
+        openItemsArray.push(item);
+      }
+      return openItemsArray;
+    }
+
+    /**
+     *  @private
+     */
+    public function set openItems(value:Object):void
+    {
+      if (value != null)
+      {
+        for each (var item:*in value)
+        {
+          _openItems[itemToUID(item)] = item;
+        }
+
+        openItemsChanged = true;
+        invalidateProperties();
+      }
+    }
+
+    /**
+     *
+     */
+    public function isBranch(item:Object):Boolean
+    {
+      if (item != null)
+        return _dataDescriptor.isBranch(item, iterator.view);
+
+      return false;
+    }
+
+    /**
+     *
+     */
+    public function isItemOpen(item:Object):Boolean
+    {
+      var uid:String = itemToUID(item);
+
+      return _openItems[uid] != null;
+    }
+
+    /**
+     *  @private
+     */
+    override public function itemToIcon(item:Object):Class
+    {
+      if (item == null)
+      {
+        return null;
+      }
+
+      var icon:*;
+      var open:Boolean = isItemOpen(item);
+      var branch:Boolean = isBranch(item);
+      var uid:String = itemToUID(item);
+
+      //first lets check the component
+      var iconClass:Class =
+        itemIcons && itemIcons[uid] ?
+        itemIcons[uid][open ? "iconID2" : "iconID"] :
+        null;
+
+      if (iconClass)
+      {
+        return iconClass;
+      }
+      else if (iconFunction != null)
+      {
+        return iconFunction(item);
+      }
+      else if (branch)
+      {
+        return getStyle(open ? "folderOpenIcon" : "folderClosedIcon");
+      }
+      else
+        //let's check the item itself
+      {
+        if (item is XML)
+        {
+          try
+          {
+            if (item[iconField].length() != 0)
+              icon = String(item[iconField]);
+          }
+          catch (e:Error)
+          {
+          }
+        }
+        else if (item is Object)
+        {
+          try
+          {
+            if (iconField && item[iconField])
+              icon = item[iconField];
+            else if (item.icon)
+              icon = item.icon;
+          }
+          catch (e:Error)
+          {
+          }
+        }
+      }
+
+      //set default leaf icon if nothing else was found
+      if (icon == null)
+        icon = getStyle("defaultLeafIcon");
+
+      //convert to the correct type and class
+      if (icon is Class)
+      {
+        return icon;
+      }
+      else if (icon is String)
+      {
+        iconClass = Class(systemManager.getDefinitionByName(String(icon)));
+        if (iconClass)
+          return iconClass;
+
+        return document[icon];
+      }
+      else
+      {
+        return Class(icon);
+      }
+
+    }
+
+    /**
+     *  Sets the associated icon for the item.  Calling this method overrides the
+     *  iconField and iconFunction properties for
+     *  this item if it is a leaf item. Branch items don't use the
+     *  iconField and iconFunction properties.
+     *  They use the folderOpenIcon and folderClosedIcon properties.
+     *
+     *  @param item Item to affect.
+     *  @param iconID Linkage ID for the closed (or leaf) icon.
+     *  @param iconID2 Linkage ID for the open icon.
+     *
+     *  @tiptext Sets the icons for the specified item
+     *  @helpid 3201
+     */
+    public function setItemIcon(item:Object, iconID:Class, iconID2:Class):void
+    {
+      if (!itemIcons)
+        itemIcons = {};
+
+      if (!iconID2)
+        iconID2 = iconID;
+
+      itemIcons[itemToUID(item)] = {iconID: iconID, iconID2: iconID2};
+
+      itemsSizeChanged = true;
+      invalidateDisplayList();
+    }
+
+    /**
+     *
+     */
+    public function closeAllItems():void
+    {
+      for (var i:int = 0; i < ICollectionView(_displayedModel).length; i++)
+      {
+        this.closeItemAt(i);
+      }
+    }
+
+    /**
+     *
+     */
+    public function closeItemAt(rowNum:Number, item:Object=null, closeItem:Boolean=true):void
+    {
+      if (item == null)
+        item = ListCollectionView(_displayedModel).getItemAt(rowNum);
+
+      if (closeItem)
+      {
+        var uid:String = itemToUID(item);
+        delete _openItems[uid];
+      }
+
+      if (_dataDescriptor.getChildren(item))
+      {
+        // recursively remove the rows that were added for child records
+        // but don't remove item from _openItems[] to keep opened items.
+        for (var i:int = 0; i < _dataDescriptor.getChildren(item).length; i++)
+        {
+          if (isItemOpen(_dataDescriptor.getChildren(item)[i]))
+          {
+            closeItemAt(rowNum, _dataDescriptor.getChildren(item)[i], false);
+          }
+
+          ListCollectionView(_displayedModel).removeItemAt(rowNum + 1);
+        }
+      }
+    }
+
+    /**
+     * @return the number of rows added to the display model
+     */
+    public function openItemAt(rowNum:Number, item:Object=null):Number
+    {
+      //if there was no item passed in then retrieve it via row number
+      if (item == null)
+        item = ListCollectionView(_displayedModel).getItemAt(rowNum);
+
+      //if the item is not already open
+      //if (!isItemOpen(item))
+      //{
+      //add the item to the list of open items
+      var uid:String = itemToUID(item);
+      _openItems[uid] = item;
+
+      var savedSelection:Array = this.selectedItems;
+      this.clearSelected();
+
+      var children:ICollectionView = _dataDescriptor.getChildren(item);
+
+      //if there are children then go and open them up, otherwise skip to the bottom and return 0
+      if (children)
+      {
+        // add the rows for the children at this level
+        for (var i:int = 0; i < children.length; i++)
+        {
+          var child:Object = children[i];
+          if (ListCollectionView(_displayedModel).contains(child) == false)
+          {
+            ListCollectionView(_displayedModel).addItemAt(child, rowNum + i + 1);
+          }
+        }
+
+        var offset:Number = 0;
+
+        for (i = 0; i < children.length; i++)
+        {
+          var vChild:Object = children[i];
+
+          if (isItemOpen(vChild))
+          {
+            offset += openItemAt(rowNum + i + 1 + offset, vChild);
+          }
+        }
+      }
+
+      super.selectedItems = savedSelection;
+
+      //return the number of children that were opened
+      return _dataDescriptor.getChildren(item).length + offset;
+      //}
+      //else {
+      //if the item was already open then return 0
+      //	return 0;
+      //}
+    }
+
+
+
+  } // end class
 } // end package


fix coding style

fix coding style

--- src/aerys/minko/type/math/Plane.as
+++ src/aerys/minko/type/math/Plane.as
@@ -364,8 +364,7 @@

 		public function toString() : String
 		{
-			return "(" + _a + ", " + _b + ", "
-				   + _c + ", " + _d + ")";
+			return '(' + _a + ', ' + _b + ', ' + _c + ', ' + _d + ')';
 		}

 		private function createGaussianFromPlanes(plane1 : Plane,


Flash drives me nuts.
Doing a loop on a null object works:
   for (s in null)
But checking to see if a property is in a null object throws an error:
   (s in null)
They're so similar!

So, protect against the NPE.

git-svn-id: a1a4b28b82a3276cc491891159dd9963a0a72fae@5233 542714f4-19e9-0310-aa3c-eee0fc999fb1

--- src/as/com/threerings/util/Util.as
+++ src/as/com/threerings/util/Util.as
@@ -52,7 +52,7 @@

         if (defaults != null) {
             for (prop in defaults) {
-                if (!(prop in initProps)) {
+                if (initProps == null || !(prop in initProps)) {
                     target[prop] = defaults[prop];
                 }
             }


Transferred from the Adobe Open Source Subversion Repository

Revision: 23246
Author:   cframpto@adobe.com
Date:     2011-12-20T17:40:08.069454Z

Log Message:
-----------
Rollback 23243.  If comment followed header it was stripped as well.

Modified Paths:
--------------
2361 paths were modified

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1290310 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/advancedgrids/src/mx/collections/SummaryObject.as
+++ frameworks/projects/advancedgrids/src/mx/collections/SummaryObject.as
@@ -1,3 +1,13 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2009 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////

 package mx.collections
 {


Transferred from the Adobe Open Source Subversion Repository

Revision: 23243
Author:   cframpto@adobe.com
Date:     2011-12-20T00:59:57.384047Z

Log Message:
-----------
In frameworks, remove Adobe headers from all files except xml/mxml file types.  There are also a few .txt files that are license files that I didn't touch yet.

Modified Paths:
--------------
2361 paths were modified

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1261560 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/framework/src/mx/managers/IActiveWindowManager.as
+++ frameworks/projects/framework/src/mx/managers/IActiveWindowManager.as
@@ -1,13 +1,3 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  ADOBE SYSTEMS INCORPORATED
-//  Copyright 2005-2007 Adobe Systems Incorporated
-//  All Rights Reserved.
-//
-//  NOTICE: Adobe permits you to use, modify, and distribute this file
-//  in accordance with the terms of the license agreement accompanying it.
-//
-////////////////////////////////////////////////////////////////////////////////

 package mx.managers
 {


Transferred from the Adobe Open Source Subversion Repository

Revision: 18880
Author:   tkraikit@adobe.com
Date:     2010-11-30T23:22:18.931945Z

Log Message:
-----------
HSliderSkin for mobile: 240ppi and 160ppi implementations.

See https://zerowing.corp.adobe.com/display/xdplatform/Slider for XD spec.

QE notes: "disabled" state still requires work -- awaiting XD input
Doc notes: n/a
Bugs: n/a
Reviewer: Jason Szeto and Jason San Jose
Tests run: checkintests, mustella(cyclone)
Is noteworthy for integration: n/a

Modified Paths:
--------------
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderDataTip.as</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderTrackSkin.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/defaults.css</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile240/assets/HSliderThumb_pressed.fxg</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile240/assets/HSliderTrack.fxg</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile160/assets/HSliderThumb_pressed.fxg</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile160/assets/HSliderTrack.fxg</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/MobileThemeClasses.as</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile240/assets/HSliderThumb_normal.fxg</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile160/assets/HSliderThumb_normal.fxg</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderSkin.as</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderThumbSkin.as</path>

git-svn-id: 7146a936b37d36e51ea0d66f8acbe0b8281bc7b7@1265330 13f79535-47bb-0310-9956-ffa450edef68

--- frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderSkin.as
+++ frameworks/projects/mobiletheme/src/spark/skins/mobile/HSliderSkin.as
@@ -0,0 +1,221 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2010 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.skins.mobile
+{
+import mx.core.ClassFactory;
+import mx.core.IFactory;
+
+import spark.components.Button;
+import spark.components.HSlider;
+import spark.skins.mobile.supportClasses.MobileSkin;
+
+/**
+ *  Actionscript based skin for HSlider on mobile applications.
+ *
+ *  The base Flex implementation creates an HSlider with fixed height
+ *  and variable width with a fixed-size thumb. As the height of the
+ *  HSlider component increases, the vertical dimensions of the visible HSlider remain
+ *  the same, and the HSlider stays vertically centered.
+ *
+ *  The thumb and track implementations can be customized by subclassing
+ *  this skin class and overriding the thumbSkinClass, trackSkinClass,
+ *  and/or dataTipClass variables as necessary.
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 2.5
+ *  @productversion Flex 4.5
+ */
+public class HSliderSkin extends MobileSkin
+{
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     *
+     */
+	public function HSliderSkin()
+	{
+		super();
+
+        thumbSkinClass = spark.skins.mobile.HSliderThumbSkin;
+        trackSkinClass = spark.skins.mobile.HSliderTrackSkin;
+        dataTipClass = HSliderDataTip;
+	}
+
+    //--------------------------------------------------------------------------
+    //
+    //  Properties
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @copy spark.skins.spark.ApplicationSkin#hostComponent
+     */
+	public var hostComponent:HSlider;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Skin parts
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  HSlider track skin part
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+	public var track:Button;
+
+    /**
+     *  HSlider thumb skin part
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+	public var thumb:Button;
+
+    /**
+     *  HSlider dataTip class factory
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    public var dataTip:IFactory;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Specifies the skin class that will be used for the HSlider thumb.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    protected var thumbSkinClass:Class;
+
+    /**
+     *  Specifies the skin class that will be used for the HSlider track.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    protected var trackSkinClass:Class;
+
+    /**
+     *  Specifies the class that will be used for the HSlider datatip.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 2.5
+     *  @productversion Flex 4.5
+     */
+    protected var dataTipClass:Class;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function commitCurrentState():void
+    {
+        if (currentState == "disabled")
+            alpha = 0.5;
+        else if (currentState == "normal")
+            alpha = 1;
+    }
+
+    /**
+     *  @private
+     */
+    override protected function createChildren():void
+    {
+        // Create our skin parts: track and thumb
+        track = new Button();
+        track.setStyle("skinClass", trackSkinClass);
+        addChild(track);
+
+        thumb = new Button();
+        thumb.setStyle("skinClass", thumbSkinClass);
+        addChild(thumb);
+
+        // Set up the class factory for the dataTip
+        dataTip = new ClassFactory();
+        ClassFactory(dataTip).generator = dataTipClass;
+    }
+
+    /**
+     *  @private
+     *  The HSliderSkin width will be no less than the width of the thumb skin.
+     *  The HSliderSkin height will be no less than the greater of the heights of
+     *  the thumb and track skins.
+     */
+    override protected function measure():void
+    {
+        measuredWidth = track.getPreferredBoundsWidth();
+        measuredHeight = Math.max(track.getPreferredBoundsHeight(), thumb.getPreferredBoundsHeight());
+
+        measuredMinHeight = Math.max(track.getPreferredBoundsHeight(), thumb.getPreferredBoundsHeight());
+        measuredMinWidth = thumb.getPreferredBoundsWidth();
+        minHeight = Math.max(track.getPreferredBoundsHeight(), thumb.getPreferredBoundsHeight());
+    }
+
+    /**
+     *  @private
+     */
+    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
+    {
+        // minimum height is no smaller than the larger of the thumb or track
+        var calculatedSkinHeight:int = Math.max(Math.max(thumb.getPreferredBoundsHeight(), track.getPreferredBoundsHeight()),
+                                                 unscaledHeight);
+
+        // minimum width is no smaller than the thumb
+        var calculatedSkinWidth:int = Math.max(thumb.getPreferredBoundsWidth(),
+                                               unscaledWidth);
+
+        // once we know the track height, center the thumb and track
+        thumb.y = Math.max(Math.round((calculatedSkinHeight - thumb.getPreferredBoundsHeight()) / 2), 0);
+        var calculatedTrackY:int = Math.max(Math.round((unscaledHeight - track.getPreferredBoundsHeight())/2), 0);
+
+        // size and position
+        resizeElement(thumb, thumb.getPreferredBoundsWidth(), thumb.getPreferredBoundsHeight()); // thumb does NOT scale
+        resizeElement(track, calculatedSkinWidth, track.getPreferredBoundsHeight()); // note track is NOT scaled vertically
+        positionElement(track, 0, calculatedTrackY);
+    }
+}
+}


Pause/Resume fix

Pause/Resume fix

--- src/com/axis/rtspclient/RTSPClient.as
+++ src/com/axis/rtspclient/RTSPClient.as
@@ -138,12 +138,10 @@

       state = STATE_PAUSE;

-      /* If in live mode, close NetSteam to discard buffer and restart display timing */
-      if (this.rtpTiming.live) {
-        this.ns.close();
-      } else {
-        this.ns.pause();
-      }
+      /* Stop timer, don't close the connection when paused. */
+      bcTimer.stop();
+
+      this.ns.pause();

       if (!this.evoStream || this.rtpTiming.live) {
         sendPauseReq();
@@ -163,7 +161,9 @@
       bcTimer.reset();
       bcTimer.start();

+      /* If in live mode, close NetSteam to discard buffer and restart display timing */
       if (this.rtpTiming.live) {
+        this.ns.close();
         this.ns.play(null);
       } else {
         this.ns.resume();
@@ -397,7 +397,7 @@
         Logger.log(parsed.headers['transport']);

         if (parsed.headers['session']) {
-          session = parsed.headers['session'];
+          session = parsed.headers['session'].match(/^[^;]+/)[0];
         }

         if (state === STATE_SETUP) {