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

	/**
	 *  The BoxItemRenderer displays a colored rectangular area suitable for use as
	 *  an itemRenderer for a BarChartSeries. This class implements the
	 *  org.apache.flex.charts.core.IChartItemRenderer
	 *  interface.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class BoxItemRenderer extends DataItemRenderer implements IChartItemRenderer
	{
		/**
		 *  constructor.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function BoxItemRenderer()
		{
			super();
		}

		override public function addedToParent():void
		{
			super.addedToParent();
		}

		override public function addBead(bead:IBead):void
		{
			super.addBead(bead);
		}

		private var _series:IChartSeries;

		/**
		 *  The series to which this itemRenderer instance belongs. Or, the series
		 *  being presented.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get series():IChartSeries
		{
			return _series;
		}
		public function set series(value:IChartSeries):void
		{
			_series = value;
		}

		private var filledRect:Rect;

		private var _yField:String = "y";

		/**
		 *  The name of the field containing the value for the Y axis.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get yField():String
		{
			return _yField;
		}
		public function set yField(value:String):void
		{
			_yField = value;
		}

		private var _xField:String = "x";

		/**
		 *  The name of the field containing the value for the X axis.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get xField():String
		{
			return _xField;
		}
		public function set xField(value:String):void
		{
			_xField = value;
		}

		private var _fill:IFill;

		/**
		 *  The color used to fill the interior of the box.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get fill():IFill
		{
			return _fill;
		}
		public function set fill(value:IFill):void
		{
			_fill = value;
		}

		private var _stroke:IStroke;

		/**
		 *  The outline of the box.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get stroke():IStroke
		{
			return _stroke;
		}
		public function set stroke(value:IStroke):void
		{
			_stroke = value;
		}

		/**
		 *  @copy org.apache.flex.supportClasses.UIItemRendererBase#data
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		override public function set data(value:Object):void
		{
			super.data = value;
			drawBar();
		}

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

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

		/**
		 *  @private
		 */
		protected function drawBar():void
		{
			if ((this.width > 0) && (this.height > 0))
			{
				var needsAdd:Boolean = false;

				if (filledRect == null) {
					filledRect = new Rect();
					needsAdd = true;
				}

				filledRect.fill = fill;
				filledRect.stroke = stroke;
				filledRect.x = 0;
				filledRect.y = 0;
				filledRect.width = this.width;
				filledRect.height = this.height;

				if (needsAdd) {
					addElement(filledRect);
				}
			}
		}

		private var hoverFill:SolidColor;

		override public function updateRenderer():void
		{
			super.updateRenderer();

			if (down||selected||hovered) {
				if (hoverFill == null) {
					hoverFill = new SolidColor();
					hoverFill.color = (fill as SolidColor).color;
					hoverFill.alpha = 0.5;
				}
				filledRect.fill = hoverFill;
			}
			else {
				filledRect.fill = fill;
			}

			filledRect.drawRect(filledRect.x, filledRect.y, filledRect.width, filledRect.height);
		}
	}
}

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

	/**
	 *  The BoxItemRenderer displays a colored rectangular area suitable for use as
	 *  an itemRenderer for a BarChartSeries. This class implements the
	 *  org.apache.flex.charts.core.IChartItemRenderer
	 *  interface.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class BoxItemRenderer extends DataItemRenderer implements IChartItemRenderer
	{
		/**
		 *  constructor.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function BoxItemRenderer()
		{
			super();
		}

		override public function addedToParent():void
		{
			super.addedToParent();
		}

		override public function addBead(bead:IBead):void
		{
			super.addBead(bead);
		}

		private var _series:IChartSeries;

		/**
		 *  The series to which this itemRenderer instance belongs. Or, the series
		 *  being presented.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get series():IChartSeries
		{
			return _series;
		}
		public function set series(value:IChartSeries):void
		{
			_series = value;
		}

		private var filledRect:Rect;

		private var _yField:String = "y";

		/**
		 *  The name of the field containing the value for the Y axis.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get yField():String
		{
			return _yField;
		}
		public function set yField(value:String):void
		{
			_yField = value;
		}

		private var _xField:String = "x";

		/**
		 *  The name of the field containing the value for the X axis.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get xField():String
		{
			return _xField;
		}
		public function set xField(value:String):void
		{
			_xField = value;
		}

		private var _fill:IFill;

		/**
		 *  The color used to fill the interior of the box.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get fill():IFill
		{
			return _fill;
		}
		public function set fill(value:IFill):void
		{
			_fill = value;
		}

		private var _stroke:IStroke;

		/**
		 *  The outline of the box.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get stroke():IStroke
		{
			return _stroke;
		}
		public function set stroke(value:IStroke):void
		{
			_stroke = value;
		}

		/**
		 *  @copy org.apache.flex.supportClasses.UIItemRendererBase#data
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		override public function set data(value:Object):void
		{
			super.data = value;
			drawBar();
		}

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

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

		/**
		 *  @private
		 */
		protected function drawBar():void
		{
			if ((this.width > 0) && (this.height > 0))
			{
				var needsAdd:Boolean = false;

				if (filledRect == null) {
					filledRect = new Rect();
					needsAdd = true;
				}

				filledRect.fill = fill;
				filledRect.stroke = stroke;
				filledRect.x = 0;
				filledRect.y = 0;
				filledRect.width = this.width;
				filledRect.height = this.height;

				if (needsAdd) {
					addElement(filledRect);
				}
			}
		}

		private var hoverFill:IFill;

		override public function updateRenderer():void
		{
			super.updateRenderer();

			if (down||selected||hovered) {
				if (hoverFill == null) {
					if(fill is SolidColor)
					{
						hoverFill = new SolidColor();
						(hoverFill as SolidColor).color = (fill as SolidColor).color;
						(hoverFill as SolidColor).alpha = 0.5;
					}
					else if(fill is LinearGradient)
					{
						hoverFill = new LinearGradient();
						(hoverFill as LinearGradient).entries = (fill as LinearGradient).entries;
						for (var i:int=0; i<(hoverFill as LinearGradient).entries; i++)
						{
							(hoverFill as LinearGradient).entries[i].alpha = 0.5;
						}
					}

				}
				filledRect.fill = hoverFill;
			}
			else {
				filledRect.fill = fill;
			}

			filledRect.drawRect(filledRect.x, filledRect.y, filledRect.width, filledRect.height);
		}
	}
}

Handle case where fill could be a LinearGradient or a SolidColor


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

    /**
     *  The ImageTextButton class implements a basic button that
     *  displays and image and text.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class ImageAndTextButton extends TextButton
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function ImageAndTextButton()
		{
			super();
		}

        /**
         *  @private
         */
        COMPILE::JS
        override public function set text(value:String):void
        {
            ImageAndTextModel(model).text = value;
            COMPILE::JS
            {
                setInnerHTML();
            }
        }

        /**
         *  The URL of an icon to use in the button
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get image():String
        {
            return ImageAndTextModel(model).image;
        }

        /**
         *  @private
         */
        public function set image(value:String):void
        {
            ImageAndTextModel(model).image = value;
            COMPILE::JS
            {
                setInnerHTML();
            }
        }

        /**
         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
         */
        COMPILE::JS
        override protected function createElement():WrappedHTMLElement
        {
            element = document.createElement('button') as WrappedHTMLElement;
            element.setAttribute('type', 'button');

            positioner = element;
            positioner.style.position = 'relative';
            element.flexjs_wrapper = this;

            return element;
        }

        /**
         */
        COMPILE::JS
        protected function setInnerHTML():void
        {
            var inner:String = '';
            if (image != null)
                inner += "<img src='" + image + "'/>";
            inner += ' ';
            inner += text;
            element.innerHTML = inner;
        };
	}
}

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

    /**
     *  The ImageTextButton class implements a basic button that
     *  displays and image and text.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class ImageAndTextButton extends TextButton
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function ImageAndTextButton()
		{
			super();
		}

        /**
         *  @private
         */
        COMPILE::JS
        override public function get text():String
        {
            return ImageAndTextModel(model).text;
        }

        /**
         *  @private
         */
        COMPILE::JS
        override public function set text(value:String):void
        {
            ImageAndTextModel(model).text = value;
            COMPILE::JS
            {
                setInnerHTML();
            }
        }

        /**
         *  The URL of an icon to use in the button
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get image():String
        {
            return ImageAndTextModel(model).image;
        }

        /**
         *  @private
         */
        public function set image(value:String):void
        {
            ImageAndTextModel(model).image = value;
            COMPILE::JS
            {
                setInnerHTML();
            }
        }

        /**
         * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
         */
        COMPILE::JS
        override protected function createElement():WrappedHTMLElement
        {
            element = document.createElement('button') as WrappedHTMLElement;
            element.setAttribute('type', 'button');

            positioner = element;
            positioner.style.position = 'relative';
            element.flexjs_wrapper = this;

            return element;
        }

        /**
         */
        COMPILE::JS
        protected function setInnerHTML():void
        {
            var inner:String = '';
            if (image != null)
                inner += "<img src='" + image + "'/>";
            inner += ' ';
            inner += text;
            element.innerHTML = inner;
        };
	}
}

fix ImageAndTextButton

fix ImageAndTextButton


package aerys.minko.scene.node.camera
{
	import aerys.minko.scene.controller.camera.CameraController;
	import aerys.minko.scene.data.CameraDataProvider;
	import aerys.minko.scene.node.AbstractSceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	public class AbstractCamera extends AbstractSceneNode
	{
		public static const DEFAULT_ZNEAR	: Number	= .1;
		public static const DEFAULT_ZFAR	: Number	= 500.;

		protected var _cameraData	: CameraDataProvider	= null;

		protected var _enabled		: Boolean				= true;

		protected var _activated	: Signal				= new Signal('Camera.activated');
		protected var _deactivated	: Signal				= new Signal('Camera.deactivated');

		public function get cameraData() : CameraDataProvider
		{
			return _cameraData;
		}

		public function get zNear() : Number
		{
			return _cameraData.zNear;
		}
		public function set zNear(value : Number) : void
		{
			_cameraData.zNear = value;
		}

		public function get zFar() : Number
		{
			return _cameraData.zFar;
		}
		public function set zFar(value : Number) : void
		{
			_cameraData.zFar = value;
		}

		public function get enabled() : Boolean
		{
			return _enabled;
		}
		public function set enabled(value : Boolean) : void
		{
			if (value != _enabled)
			{
				_enabled = value;

				if (_enabled)
					_activated.execute(this);
				else
					_deactivated.execute(this);
			}
		}

		public function get activated() : Signal
		{
			return _activated;
		}
		public function get deactivated() : Signal
		{
			return _deactivated;
		}

		public function get worldToView() : Matrix4x4
		{
			return worldToLocal;
		}

		public function get viewToWorld() : Matrix4x4
		{
			return localToWorld;
		}

		public function get worldToScreen() : Matrix4x4
		{
			return _cameraData.worldToScreen;
		}

		public function AbstractCamera(zNear	: Number = DEFAULT_ZNEAR,
									   zFar		: Number = DEFAULT_ZFAR)
		{
			super();

			_cameraData = new CameraDataProvider(worldToView, viewToWorld);

			_cameraData.zNear 	= zNear;
			_cameraData.zFar 	= zFar;

			initialize();
		}

		protected function initialize() : void
		{
			throw new Error('Must be overriden.');
		}

		public function unproject(x : Number, u : Number, out : Ray = null) : Ray
		{
			throw new Error('Must be overriden.');
		}

		public function getWorldToScreen(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.worldToScreen)
				: _cameraData.worldToScreen.clone();
		}

		public function getScreenToWorld(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.screenToWorld)
				: _cameraData.screenToWorld.clone();
		}

		public function getProjection(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.projection)
				: _cameraData.projection.clone();
		}
	}
}

package aerys.minko.scene.node.camera
{
	import aerys.minko.scene.controller.camera.CameraController;
	import aerys.minko.scene.data.CameraDataProvider;
	import aerys.minko.scene.node.AbstractSceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Ray;

	public class AbstractCamera extends AbstractSceneNode
	{
		public static const DEFAULT_ZNEAR	: Number	= .1;
		public static const DEFAULT_ZFAR	: Number	= 500.;

		protected var _cameraData	: CameraDataProvider	= null;

		protected var _enabled		: Boolean				= true;

		protected var _activated	: Signal				= new Signal('Camera.activated');
		protected var _deactivated	: Signal				= new Signal('Camera.deactivated');

		public function get cameraData() : CameraDataProvider
		{
			return _cameraData;
		}

		public function get zNear() : Number
		{
			return _cameraData.zNear;
		}
		public function set zNear(value : Number) : void
		{
			_cameraData.zNear = value;
		}

		public function get zFar() : Number
		{
			return _cameraData.zFar;
		}
		public function set zFar(value : Number) : void
		{
			_cameraData.zFar = value;
		}

		public function get enabled() : Boolean
		{
			return _enabled;
		}
		public function set enabled(value : Boolean) : void
		{
			if (value != _enabled)
			{
				_enabled = value;

				if (_enabled)
					_activated.execute(this);
				else
					_deactivated.execute(this);
			}
		}

		public function get activated() : Signal
		{
			return _activated;
		}
		public function get deactivated() : Signal
		{
			return _deactivated;
		}

		public function get worldToView() : Matrix4x4
		{
			return worldToLocal;
		}

		public function get viewToWorld() : Matrix4x4
		{
			return localToWorld;
		}

		public function get worldToScreen() : Matrix4x4
		{
			return _cameraData.worldToScreen;
		}

		public function AbstractCamera(zNear	: Number = DEFAULT_ZNEAR,
									   zFar		: Number = DEFAULT_ZFAR)
		{
			super();

			_cameraData = new CameraDataProvider(worldToView, viewToWorld);

			_cameraData.zNear 	= zNear;
			_cameraData.zFar 	= zFar;

			initialize();
		}

		protected function initialize() : void
		{
			throw new Error('Must be overriden.');
		}

		public function unproject(x : Number, v : Number, out : Ray = null) : Ray
		{
			throw new Error('Must be overriden.');
		}

		public function getWorldToScreen(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.worldToScreen)
				: _cameraData.worldToScreen.clone();
		}

		public function getScreenToWorld(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.screenToWorld)
				: _cameraData.screenToWorld.clone();
		}

		public function getProjection(output : Matrix4x4) : Matrix4x4
		{
			return output != null
				? output.copyFrom(_cameraData.projection)
				: _cameraData.projection.clone();
		}
	}
}

fix typo

fix typo


package stdio {
  import flash.display.*
  import flash.events.*
  import flash.utils.*
  import flash.net.*

  public class StandardProcess implements Process {
    private const buffered_stdin: BufferedStream = new BufferedStream
    private const stdin_socket: SocketStream = new SocketStream
    private const readline_socket: SocketStream = new SocketStream

    private const stdout_socket: SocketStream = new SocketStream
    private const stderr_socket: SocketStream = new SocketStream

    private var _env: Object
    private var _prompt: String = "> "

    public function StandardProcess(env: Object) {
      _env = env
    }

    public function initialize(callback: Function): void {
      if (available) {
        connect(callback)
      } else {
        callback()
      }
    }

    public function get available(): Boolean {
      return env["stdio.enabled"]
    }

    private function get http_url(): String {
      return env["stdio.http"]
    }

    private function get interactive(): Boolean {
      return env["stdio.interactive"] === "true"
    }

    private function connect(callback: Function): void {
      stdin_socket.onopen = onopen
      readline_socket.onopen = onopen
      stdout_socket.onopen = onopen
      stderr_socket.onopen = onopen

      var n: int = 0

      function onopen(): void {
        if (++n === 3) {
          callback()
        }
      }

      stdin_socket.ondata = buffered_stdin.write
      stdin_socket.onclose = buffered_stdin.close
      readline_socket.ondata = buffered_stdin.write
      readline_socket.onclose = buffered_stdin.close

      const stdin_port: int = get_int("stdio.in")
      const readline_port: int = get_int("stdio.readline")

      if (interactive) {
        readline_socket.connect("localhost", readline_port)
      } else {
        stdin_socket.connect("localhost", stdin_port)
      }

      const stdout_port: int = get_int("stdio.out")
      const stderr_port: int = get_int("stdio.err")

      stdout_socket.connect("localhost", stdout_port)
      stderr_socket.connect("localhost", stderr_port)

      function get_int(name: String): int {
        return parseInt(env[name])
      }
    }

    //----------------------------------------------------------------

    public function get env(): * {
      return _env
    }

    public function get argv(): Array {
      if (env["stdio.argv"] === "") {
        return []
      } else {
        return env["stdio.argv"].split(" ").map(
          function (argument: String, ...rest: Array): String {
            return decodeURIComponent(argument)
          }
        )
      }
    }

    public function puts(value: *): void {
      if (available) {
        if (interactive) {
          readline_socket.puts("!" + value)
        } else {
          stdout.puts(value)
        }
      } else {
        debug.show("puts: " + value)
      }
    }

    public function warn(value: *): void {
      if (available) {
        stderr.puts(value)
      } else {
        debug.show("warn: " + value)
      }
    }

    public function die(value: *): void {
      if (available) {
        warn(value); exit(-1)
      } else {
        throw new Error("fatal error: " + String(value))
      }
    }

    public function style(styles: String, string: String): String {
      const codes: Object = {
        none: 0, bold: 1, italic: 3, underline: 4, inverse: 7,
        black: 30, red: 31, green: 32, yellow: 33, blue: 34,
        magenta: 35, cyan: 36, white: 37, gray: 90, grey: 90
      }

      if (styles === "") {
        return string
      } else {
        return styles.split(/\s+/).map(
          function (style: String, ...rest: Array): String {
            if (style in codes) {
              return escape_sequence(codes[style])
            } else {
              throw new Error("style not supported: " + style)
            }
          }
        ).join("") + string + escape_sequence(0)
      }

      function escape_sequence(code: int): String {
        return "\x1b[" + code + "m"
      }
    }

    public function gets(callback: Function): void {
      if (available) {
        if (interactive) {
          readline_socket.puts("?" + _prompt)
        }

        stdin.gets(callback)
      } else {
        callback(null)
      }
    }

    public function set prompt(value: String): void {
      _prompt = value
    }

    public function get stdin(): InputStream {
      return buffered_stdin
    }

    public function get stdout(): OutputStream {
      return stdout_socket
    }

    public function get stderr(): OutputStream {
      return stderr_socket
    }

    public function handle(error: *): void {
      if (error is UncaughtErrorEvent) {
        UncaughtErrorEvent(error).preventDefault()
        handle(UncaughtErrorEvent(error).error)
        exit(-1)
      } else if (error is Error) {
        // Important: Avoid the `Error(x)` casting syntax.
        http_post("/error", (error as Error).getStackTrace())
      } else if (error is ErrorEvent) {
        http_post("/error", (error as ErrorEvent).text)
      } else {
        http_post("/error", String(error))
      }
    }

    private function shell_quote(word: String): String {
      if (/^[-=.,\w]+$/.test(word)) {
        return word
      } else {
        return "'" + word.replace(/'/g, "'\\''") + "'"
      }
    }

    public function exec(
      command: *,
      callback: Function,
      errback: Function = null
    ): void {
      if (available) {
        var stdin: String = ""

        if (isPlainObject(command)) {
          if ("command" in command && "stdin" in command) {
            stdin = command.stdin
            command = command.command
          } else {
            throw new Error("bad command object: %i", command)
          }
        }

        if (command is String) {
          command = ["sh", "-c", command]
        }

        const url: String = "/exec?" + map(
          command, encodeURIComponent
        ).join("&")

        http_post(url, stdin, function (data: String): void {
          const result: XML = new XML(data)
          const status: int = result.@status
          const stdout: String = result.stdout.text()
          const stderr: String = result.stderr.text()

          if (status === 0) {
            if (callback.length === 1) {
              callback(stdout)
            } else {
              callback(stdout, stderr)
            }
          } else if (errback === null) {
            warn(stderr)
          } else if (errback.length === 1) {
            errback(status)
          } else if (errback.length === 2) {
            errback(status, stderr)
          } else {
            errback(status, stderr, stdout)
          }
        })
      } else {
        throw new Error("cannot execute command: process not available")
      }
    }

    public function exit(status: int = 0): void {
      if (available) {
        when_ready(function (): void {
          http_post("/exit", String(status))
        })
      } else {
        throw new Error("cannot exit: process not available")
      }
    }

    //----------------------------------------------------------------

    private var n_pending_requests: int = 0
    private var ready_callbacks: Array = []

    private function when_ready(callback: Function): void {
      if (n_pending_requests === 0) {
        callback()
      } else {
        ready_callbacks.push(callback)
      }
    }

    private function handle_ready(): void {
      for each (var callback: Function in ready_callbacks) {
        callback()
      }

      ready_callbacks = []
    }

    private function http_post(
      path: String, content: String, callback: Function = null
    ): void {
      const request: URLRequest = new URLRequest(http_url + path)

      request.method = "POST"
      request.data = content

      const loader: URLLoader = new URLLoader

      ++n_pending_requests

      loader.addEventListener(
        Event.COMPLETE,
        function (event: Event): void {
          if (callback !== null) {
            callback(loader.data)
          }

          if (--n_pending_requests === 0) {
            handle_ready()
          }
        }
      )

      loader.load(request)
    }
  }
}

package stdio {
  import flash.display.*
  import flash.events.*
  import flash.utils.*
  import flash.net.*

  public class StandardProcess implements Process {
    private const buffered_stdin: BufferedStream = new BufferedStream
    private const stdin_socket: SocketStream = new SocketStream
    private const readline_socket: SocketStream = new SocketStream

    private const stdout_socket: SocketStream = new SocketStream
    private const stderr_socket: SocketStream = new SocketStream

    private var _env: Object
    private var _prompt: String = "> "

    public function StandardProcess(env: Object) {
      _env = env
    }

    public function initialize(callback: Function): void {
      if (available) {
        connect(callback)
      } else {
        callback()
      }
    }

    public function get available(): Boolean {
      return env["stdio.enabled"]
    }

    private function get http_url(): String {
      return env["stdio.http"]
    }

    private function get interactive(): Boolean {
      return env["stdio.interactive"] === "true"
    }

    private function connect(callback: Function): void {
      stdin_socket.onopen = onopen
      readline_socket.onopen = onopen
      stdout_socket.onopen = onopen
      stderr_socket.onopen = onopen

      var n: int = 0

      function onopen(): void {
        if (++n === 3) {
          callback()
        }
      }

      stdin_socket.ondata = buffered_stdin.write
      stdin_socket.onclose = buffered_stdin.close
      readline_socket.ondata = buffered_stdin.write
      readline_socket.onclose = buffered_stdin.close

      const stdin_port: int = get_int("stdio.in")
      const readline_port: int = get_int("stdio.readline")

      if (interactive) {
        readline_socket.connect("localhost", readline_port)
      } else {
        stdin_socket.connect("localhost", stdin_port)
      }

      const stdout_port: int = get_int("stdio.out")
      const stderr_port: int = get_int("stdio.err")

      stdout_socket.connect("localhost", stdout_port)
      stderr_socket.connect("localhost", stderr_port)

      function get_int(name: String): int {
        return parseInt(env[name])
      }
    }

    //----------------------------------------------------------------

    public function get env(): * {
      return _env
    }

    public function get argv(): Array {
      if (env["stdio.argv"] === "") {
        return []
      } else {
        return env["stdio.argv"].split(" ").map(
          function (argument: String, ...rest: Array): String {
            return decodeURIComponent(argument)
          }
        )
      }
    }

    public function puts(value: *): void {
      if (available) {
        if (interactive) {
          readline_socket.puts("!" + value)
        } else {
          stdout.puts(value)
        }
      } else {
        debug.show("puts: " + value)
      }
    }

    public function warn(value: *): void {
      if (available) {
        stderr.puts(value)
      } else {
        debug.show("warn: " + value)
      }
    }

    public function die(value: *): void {
      if (available) {
        warn(value); exit(-1)
      } else {
        throw new Error("fatal error: " + String(value))
      }
    }

    public function style(styles: String, string: String): String {
      const codes: Object = {
        none: 0, bold: 1, italic: 3, underline: 4, inverse: 7,
        black: 30, red: 31, green: 32, yellow: 33, blue: 34,
        magenta: 35, cyan: 36, white: 37, gray: 90, grey: 90
      }

      if (styles === "") {
        return string
      } else {
        return styles.split(/\s+/).map(
          function (style: String, ...rest: Array): String {
            if (style in codes) {
              return escape_sequence(codes[style])
            } else {
              throw new Error("style not supported: " + style)
            }
          }
        ).join("") + string + escape_sequence(0)
      }

      function escape_sequence(code: int): String {
        return "\x1b[" + code + "m"
      }
    }

    public function gets(callback: Function): void {
      if (available) {
        if (interactive) {
          readline_socket.puts("?" + _prompt)
        }

        stdin.gets(callback)
      } else {
        callback(null)
      }
    }

    public function set prompt(value: String): void {
      _prompt = value
    }

    public function get stdin(): InputStream {
      return buffered_stdin
    }

    public function get stdout(): OutputStream {
      return stdout_socket
    }

    public function get stderr(): OutputStream {
      return stderr_socket
    }

    public function handle(error: *): void {
      if (error is UncaughtErrorEvent) {
        UncaughtErrorEvent(error).preventDefault()
        handle(UncaughtErrorEvent(error).error)
        exit(-1)
      } else if (error is Error) {
        // Important: Avoid the `Error(x)` casting syntax.
        http_post("/error", (error as Error).getStackTrace())
      } else if (error is ErrorEvent) {
        http_post("/error", (error as ErrorEvent).text)
      } else {
        http_post("/error", String(error))
      }
    }

    private function shell_quote(word: String): String {
      if (/^[-=.,\w]+$/.test(word)) {
        return word
      } else {
        return "'" + word.replace(/'/g, "'\\''") + "'"
      }
    }

    public function exec(
      command: *,
      callback: Function,
      errback: Function = null
    ): void {
      if (available) {
        var stdin: String = ""

        if (isPlainObject(command)) {
          if ("command" in command && "stdin" in command) {
            stdin = command.stdin
            command = command.command
          } else {
            throw new Error("bad command object: %i", command)
          }
        }

        if (command is String) {
          command = ["sh", "-c", command]
        }

        const url: String = "/exec?" + map(
          command, encodeURIComponent
        ).join("&")

        http_post(url, stdin, function (data: String): void {
          const result: XML = new XML(data)
          const status: int = result.@status
          const stdout: String = result.stdout.text()
          const stderr: String = result.stderr.text()

          if (status === 0) {
            if (callback.length === 1) {
              callback(stdout)
            } else {
              callback(stdout, stderr)
            }
          } else if (errback === null) {
            warn(stderr)
          } else if (errback.length === 1) {
            errback(new Error(stderr))
          } else if (errback.length === 2) {
            errback(status, stderr)
          } else {
            errback(status, stderr, stdout)
          }
        })
      } else {
        throw new Error("cannot execute command: process not available")
      }
    }

    public function exit(status: int = 0): void {
      if (available) {
        when_ready(function (): void {
          http_post("/exit", String(status))
        })
      } else {
        throw new Error("cannot exit: process not available")
      }
    }

    //----------------------------------------------------------------

    private var n_pending_requests: int = 0
    private var ready_callbacks: Array = []

    private function when_ready(callback: Function): void {
      if (n_pending_requests === 0) {
        callback()
      } else {
        ready_callbacks.push(callback)
      }
    }

    private function handle_ready(): void {
      for each (var callback: Function in ready_callbacks) {
        callback()
      }

      ready_callbacks = []
    }

    private function http_post(
      path: String, content: String, callback: Function = null
    ): void {
      const request: URLRequest = new URLRequest(http_url + path)

      request.method = "POST"
      request.data = content

      const loader: URLLoader = new URLLoader

      ++n_pending_requests

      loader.addEventListener(
        Event.COMPLETE,
        function (event: Event): void {
          if (callback !== null) {
            callback(loader.data)
          }

          if (--n_pending_requests === 0) {
            handle_ready()
          }
        }
      )

      loader.load(request)
    }
  }
}

Change `process.exec` to pass an Error instance to its errback.


package aerys.minko.scene.controller.light
{
	import aerys.minko.scene.data.LightDataProvider;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.scene.node.light.AbstractLight;
	import aerys.minko.scene.node.light.PointLight;
	import aerys.minko.type.enum.ShadowMappingType;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Vector4;

	/**
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class PointLightController extends LightShadowController
	{
		private var _worldPosition	: Vector4;
		private var _projection		: Matrix4x4;

		public function PointLightController()
		{
			super(
				PointLight,
				ShadowMappingType.PCF
				| ShadowMappingType.DUAL_PARABOLOID
				| ShadowMappingType.VARIANCE
				| ShadowMappingType.EXPONENTIAL
			);

			initialize();
		}

		private function initialize() : void
		{
			_worldPosition = new Vector4();
			_projection = new Matrix4x4();
		}

		override protected function targetAddedHandler(ctrl	: LightController,
													  light	: AbstractLight) : void
		{
			super.targetAddedHandler(ctrl, light);

			lightData.setLightProperty('worldPosition', _worldPosition);
			lightData.setLightProperty('projection', _projection);
		}

		override protected function lightAddedToScene(scene : Scene) : void
		{
			super.lightAddedToScene(scene);

            light.localToWorld(Vector4.ZERO, _worldPosition);
			updateProjectionMatrix();

            light.localToWorldTransformChanged.add(lightLocalToWorldTransformChangedHandler);
		}

        protected function lightLocalToWorldTransformChangedHandler(light         : AbstractLight,
                                                                    localToWorld  : Matrix4x4) : void
		{
			localToWorld.getTranslation(_worldPosition);
		}

		override protected function lightDataChangedHandler(lightData		: LightDataProvider,
															propertyName	: String,
															bindingName		: String,
															value			: Object) : void
		{
			super.lightDataChangedHandler(lightData, propertyName, bindingName, propertyName);

			propertyName = LightDataProvider.getPropertyName(propertyName);

			if (propertyName == 'shadowZNear' || propertyName == 'shadowZFar')
				updateProjectionMatrix();
		}

		private function updateProjectionMatrix() : void
		{
			var zNear	: Number	= lightData.getLightProperty('shadowZNear');
			var zFar	: Number	= lightData.getLightProperty('shadowZFar');
			var fd		: Number	= 1. / Math.tan(Math.PI / 4);
			var m33		: Number	= 1. / (zFar - zNear);
			var m43		: Number	= -zNear / (zFar - zNear);

			_projection.initialize(
				fd,		0.,		0., 	0.,
				0., 	fd, 	0.,		0.,
				0., 	0., 	m33, 	1.,
				0., 	0., 	m43, 	0.
			);
		}
	}
}

package aerys.minko.scene.controller.light
{
	import aerys.minko.scene.data.LightDataProvider;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.scene.node.light.AbstractLight;
	import aerys.minko.scene.node.light.PointLight;
	import aerys.minko.type.enum.ShadowMappingType;
	import aerys.minko.type.math.Matrix4x4;
	import aerys.minko.type.math.Vector4;

	/**
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public final class PointLightController extends LightShadowController
	{
		private var _worldPosition	: Vector4;
		private var _projection		: Matrix4x4;

		public function PointLightController()
		{
			super(
				PointLight,
				ShadowMappingType.PCF
				| ShadowMappingType.DUAL_PARABOLOID
				| ShadowMappingType.VARIANCE
				| ShadowMappingType.EXPONENTIAL
			);

			initialize();
		}

		private function initialize() : void
		{
			_worldPosition = new Vector4();
			_projection = new Matrix4x4();
		}

		override protected function targetAddedHandler(ctrl	: LightController,
													   light	: AbstractLight) : void
		{
			super.targetAddedHandler(ctrl, light);

			lightData.setLightProperty('worldPosition', _worldPosition);
			lightData.setLightProperty('projection', _projection);
		}

		override protected function lightAddedToScene(scene : Scene) : void
		{
			super.lightAddedToScene(scene);

			light.localToWorld(Vector4.ZERO, _worldPosition);
			updateProjectionMatrix();
			light.localToWorldTransformChanged.add(lightLocalToWorldTransformChangedHandler);
		}

		override protected function lightRemovedFromScene(scene:Scene):void
		{
			super.lightRemovedFromScene(scene);
			light.localToWorldTransformChanged.remove(lightLocalToWorldTransformChangedHandler);
		}

		protected function lightLocalToWorldTransformChangedHandler(light         : AbstractLight,
																	localToWorld  : Matrix4x4) : void
		{
			localToWorld.getTranslation(_worldPosition);
		}

		override protected function lightDataChangedHandler(lightData		: LightDataProvider,
															propertyName	: String,
															bindingName		: String,
															value			: Object) : void
		{
			super.lightDataChangedHandler(lightData, propertyName, bindingName, propertyName);

			propertyName = LightDataProvider.getPropertyName(propertyName);

			if (propertyName == 'shadowZNear' || propertyName == 'shadowZFar')
				updateProjectionMatrix();
		}

		private function updateProjectionMatrix() : void
		{
			var zNear	: Number	= lightData.getLightProperty('shadowZNear');
			var zFar	: Number	= lightData.getLightProperty('shadowZFar');
			var fd		: Number	= 1. / Math.tan(Math.PI / 4);
			var m33		: Number	= 1. / (zFar - zNear);
			var m43		: Number	= -zNear / (zFar - zNear);

			_projection.initialize(
				fd,		0.,		0., 	0.,
				0., 	fd, 	0.,		0.,
				0., 	0., 	m33, 	1.,
				0., 	0., 	m43, 	0.
			);
		}
	}
}

Remove a point light remove signal properly


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

	import org.apache.flex.core.IBead;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.IDocument;

    /**
     *  The SimpleBinding class is lightweight data-binding class that
     *  is optimized for simple assignments of one object's property to
     *  another object's property.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class SimpleBinding implements IBead, IDocument
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function SimpleBinding()
		{
		}

        /**
         *  The source object that dispatches an event
         *  when the property changes
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		protected var source:IEventDispatcher;

        /**
         *  The host mxml document for the source and
         *  destination objects.  The source object
         *  is either this document for simple bindings
         *  like {foo} where foo is a property on
         *  the mxml documnet, or found as document[sourceID]
         *  for simple bindings like {someid.someproperty}
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        protected var document:Object;

        /**
         *  The destination object.  It is always the same
         *  as the strand.  SimpleBindings are attached to
         *  the strand of the destination object.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		protected var destination:Object;

        /**
         *  If not null, the id of the mxml tag who's property
         *  is being watched for changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var sourceID:String;

        /**
         *  If not null, the name of a property on the
         *  mxml document that is being watched for changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var sourcePropertyName:String;

        /**
         *  The event name that is dispatched when the source
         *  property changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var eventName:String;

        /**
         *  The name of the property on the strand that
         *  is set when the source property changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var destinationPropertyName:String;

        /**
         *  @copy org.apache.flex.core.IBead#strand
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function set strand(value:IStrand):void
		{
			destination = value;
            if (sourceID != null)
    			source = document[sourceID] as IEventDispatcher;
            else
                source = document as IEventDispatcher;
			source.addEventListener(eventName, changeHandler);
			destination[destinationPropertyName] = source[sourcePropertyName];
		}

        /**
         *  @copy org.apache.flex.core.IDocument#setDocument()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function setDocument(document:Object, id:String = null):void
		{
			this.document = document;
		}

		private function changeHandler(event:Event):void
		{
			destination[destinationPropertyName] = source[sourcePropertyName];
		}
	}
}

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

	import org.apache.flex.core.IBead;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.core.IDocument;

    /**
     *  The SimpleBinding class is lightweight data-binding class that
     *  is optimized for simple assignments of one object's property to
     *  another object's property.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class SimpleBinding implements IBead, IDocument
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function SimpleBinding()
		{
		}

        /**
         *  The source object that dispatches an event
         *  when the property changes
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		protected var source:IEventDispatcher;

        /**
         *  The host mxml document for the source and
         *  destination objects.  The source object
         *  is either this document for simple bindings
         *  like {foo} where foo is a property on
         *  the mxml documnet, or found as document[sourceID]
         *  for simple bindings like {someid.someproperty}
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        protected var document:Object;

        /**
         *  The destination object.  It is always the same
         *  as the strand.  SimpleBindings are attached to
         *  the strand of the destination object.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var destination:Object;

        /**
         *  If not null, the id of the mxml tag who's property
         *  is being watched for changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var sourceID:String;

        /**
         *  If not null, the name of a property on the
         *  mxml document that is being watched for changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public var sourcePropertyName:String;

        /**
         *  The event name that is dispatched when the source
         *  property changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var eventName:String;

        /**
         *  The name of the property on the strand that
         *  is set when the source property changes.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public var destinationPropertyName:String;

        /**
         *  @copy org.apache.flex.core.IBead#strand
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function set strand(value:IStrand):void
		{
			if (destination == null)
                destination = value;
            if (sourceID != null)
    			source = document[sourceID] as IEventDispatcher;
            else
                source = document as IEventDispatcher;
			source.addEventListener(eventName, changeHandler);
			destination[destinationPropertyName] = source[sourcePropertyName];
		}

        /**
         *  @copy org.apache.flex.core.IDocument#setDocument()
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function setDocument(document:Object, id:String = null):void
		{
			this.document = document;
		}

		private function changeHandler(event:Event):void
		{
			destination[destinationPropertyName] = source[sourcePropertyName];
		}
	}
}

allow override of desitination so SimpleBinding can be used for non-strands


package aerys.minko.scene.visitor.data
{
	import aerys.minko.type.math.Matrix4x4;

	public final class LocalData
	{
		public static const VIEW						: String = 'view';
		public static const WORLD						: String = 'world';
		public static const PROJECTION					: String = 'projection';

		public static const WORLD_INVERSE				: String = 'worldInverse';
		public static const VIEW_INVERSE				: String = 'viewInverse';
		public static const PROJECTION_INVERSE			: String = 'projectionInverse';

		public static const LOCAL_TO_VIEW				: String = 'localToView';
		public static const LOCAL_TO_SCREEN				: String = 'localToScreen';
		public static const LOCAL_TO_UV					: String = 'localToUv';

		private static const UPDATE_NONE				: uint		= 0;
		private static const UPDATE_WORLD_TO_LOCAL		: uint		= 1;
		private static const UPDATE_CAMERA_POSITION		: uint		= 2;
		private static const UPDATE_LOCAL_TO_VIEW		: uint		= 4;
		private static const UPDATE_LOCAL_TO_SCREEN		: uint		= 8;
		private static const UPDATE_VIEW_TO_LOCAL		: uint		= 16;
		private static const UPDATE_ALL					: uint		= UPDATE_WORLD_TO_LOCAL
																	  | UPDATE_CAMERA_POSITION
																	  | UPDATE_LOCAL_TO_VIEW
																	  | UPDATE_LOCAL_TO_SCREEN
																	  | UPDATE_VIEW_TO_LOCAL;

		private var _update								: uint			= 0;

		private var _world								: Matrix4x4		= new Matrix4x4();
		private var _view								: Matrix4x4		= new Matrix4x4();
		private var _projection							: Matrix4x4		= new Matrix4x4();
		private var _viewInverse						: Matrix4x4		= null;
		private var _viewInverse_viewVersion			: uint			= 0;

		private var _worldInverse						: Matrix4x4		= null;
		private var _worldInverse_worldVersion			: uint			= 0;

		private var _localToView						: Matrix4x4		= null;
		private var _localToView_viewVersion			: uint			= 0;
		private var _localToView_worldVersion			: uint			= 0;

		private var _localToScreen						: Matrix4x4		= null;
		private var _localToScreen_localToViewVersion 	: uint			= 0;
		private var _localToScreen_projectionVersion	: uint			= 0;

		private var _localToUv							: Matrix4x4		= null;
		private var _localToUv_localToScreenVersion		: uint			= 0;

		public function get view() : Matrix4x4
		{
			return _view;
		}

		public function get world() : Matrix4x4
		{
			return _world;
		}

		public function get projection() : Matrix4x4
		{
			return _projection;
		}

		public function get worldInverse() : Matrix4x4
		{
			var worldMatrix : Matrix4x4 = world;

			if (_worldInverse_worldVersion != worldMatrix.version)
			{
				_worldInverse = Matrix4x4.invert(worldMatrix, _worldInverse);
				_worldInverse_worldVersion = worldMatrix.version;
			}

			return _worldInverse;
		}

		public function get viewInverse() : Matrix4x4
		{
			var viewMatrix : Matrix4x4 = view;

			if (_viewInverse_viewVersion != viewMatrix.version)
			{
				_viewInverse = Matrix4x4.invert(viewMatrix, _viewInverse);
				_viewInverse_viewVersion = viewMatrix.version;
			}

			return _viewInverse;
		}

		public function get localToView() : Matrix4x4
		{
			var worldMatrix	: Matrix4x4 = world;
			var viewMatrix	: Matrix4x4 = view;

			if (_localToView_worldVersion != worldMatrix.version ||
				_localToView_viewVersion != viewMatrix.version)
			{
				_localToView = Matrix4x4.multiply(viewMatrix, worldMatrix, _localToView);
				_localToView_worldVersion	= worldMatrix.version;
				_localToView_viewVersion	= viewMatrix.version;
			}

			return _localToView;
		}

		public function get localToScreen() : Matrix4x4
		{
			var localToViewMatrix	: Matrix4x4 = localToView;
			var projectionMatrix	: Matrix4x4 = projection;

			if (_localToScreen_localToViewVersion != localToViewMatrix.version ||
				_localToScreen_projectionVersion != projectionMatrix.version)
			{
				_localToScreen = Matrix4x4.multiply(projectionMatrix, localToViewMatrix, _localToScreen);
				_localToScreen_localToViewVersion	= localToViewMatrix.version;
				_localToScreen_projectionVersion	= projectionMatrix.version;
			}

			return _localToScreen;
		}

		/**
		 * FIXME
		 */
		public function get screentoUv() : Matrix4x4
		{
			var offset : Number = 0.5 + (0.5 / 2048);
			return new Matrix4x4(
				0.5,		0.0,		0.0,	0.0,
				0.0, 		-0.5,		0.0,	0.0,
				0.0,		0.0,		1.0,	0.0,
				offset, 	offset,		0.0, 	1.0
			);
		}

		public function get localToUv() : Matrix4x4
		{
			var localToScreenMatrix : Matrix4x4 = localToScreen;
			var screenToUvMatrix	: Matrix4x4 = screentoUv;

			if (_localToUv_localToScreenVersion != localToScreenMatrix.version)
			{
				_localToUv = Matrix4x4.multiply(screenToUvMatrix, localToScreenMatrix);
				_localToUv_localToScreenVersion = localToScreenMatrix.version;
			}

			return _localToUv;
		}

		public function set world(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _world);
			_update |= UPDATE_LOCAL_TO_SCREEN | UPDATE_LOCAL_TO_VIEW | UPDATE_WORLD_TO_LOCAL;
		}

		public function set view(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _view);
			_update |= UPDATE_LOCAL_TO_SCREEN | UPDATE_LOCAL_TO_VIEW | UPDATE_VIEW_TO_LOCAL;
		}

		public function set projection(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _projection);
			_update |= UPDATE_LOCAL_TO_SCREEN;
		}

		public function LocalData()
		{
			reset();
		}

		public function reset() : void
		{
			_viewInverse_viewVersion = uint.MAX_VALUE;

			_worldInverse_worldVersion = uint.MAX_VALUE;

			_localToView_viewVersion = uint.MAX_VALUE;
			_localToView_worldVersion = uint.MAX_VALUE;

			_localToScreen_localToViewVersion = uint.MAX_VALUE;
			_localToScreen_projectionVersion = uint.MAX_VALUE;
		}
	}
}

package aerys.minko.scene.visitor.data
{
	import aerys.minko.type.math.Matrix4x4;

	public final class LocalData
	{
		private static const _SCREEN_TO_UV : Matrix4x4 = new Matrix4x4(
			0.5,		0.0,		0.0,	0.0,
			0.0, 		-0.5,		0.0,	0.0,
			0.0,		0.0,		1.0,	0.0,
			0.5, 		0.5,		0.0, 	1.0
		);

		public static const VIEW						: String = 'view';
		public static const WORLD						: String = 'world';
		public static const PROJECTION					: String = 'projection';

		public static const WORLD_INVERSE				: String = 'worldInverse';
		public static const VIEW_INVERSE				: String = 'viewInverse';

		public static const SCREEN_TO_UV				: String = 'screenToUv';

		public static const LOCAL_TO_VIEW				: String = 'localToView';
		public static const LOCAL_TO_SCREEN				: String = 'localToScreen';
		public static const LOCAL_TO_UV					: String = 'localToUv';

		protected var _world							: Matrix4x4;
		protected var _view								: Matrix4x4;
		protected var _projection						: Matrix4x4;

		protected var _viewInverse						: Matrix4x4;
		protected var _viewInverse_viewVersion			: uint;

		protected var _worldInverse						: Matrix4x4;
		protected var _worldInverse_worldVersion		: uint;

		protected var _localToView						: Matrix4x4;
		protected var _localToView_viewVersion			: uint;
		protected var _localToView_worldVersion			: uint;

		protected var _localToScreen					: Matrix4x4;
		protected var _localToScreen_localToViewVersion : uint;
		protected var _localToScreen_projectionVersion	: uint;

		protected var _localToUv						: Matrix4x4;
		protected var _localToUv_localToScreenVersion	: uint;

		public function get view() : Matrix4x4
		{
			return _view;
		}

		public function get world() : Matrix4x4
		{
			return _world;
		}

		public function get projection() : Matrix4x4
		{
			return _projection;
		}

		public function get worldInverse() : Matrix4x4
		{
			var worldMatrix : Matrix4x4 = world;

			if (_worldInverse_worldVersion != worldMatrix.version)
			{
				_worldInverse = Matrix4x4.invert(worldMatrix, _worldInverse);
				_worldInverse_worldVersion = worldMatrix.version;
			}

			return _worldInverse;
		}

		public function get viewInverse() : Matrix4x4
		{
			var viewMatrix : Matrix4x4 = view;

			if (_viewInverse_viewVersion != viewMatrix.version)
			{
				_viewInverse = Matrix4x4.invert(viewMatrix, _viewInverse);
				_viewInverse_viewVersion = viewMatrix.version;
			}

			return _viewInverse;
		}

		public function get localToView() : Matrix4x4
		{
			var worldMatrix	: Matrix4x4 = world;
			var viewMatrix	: Matrix4x4 = view;

			if (_localToView_worldVersion != worldMatrix.version ||
				_localToView_viewVersion != viewMatrix.version)
			{
				_localToView = Matrix4x4.multiply(viewMatrix, worldMatrix, _localToView);
				_localToView_worldVersion	= worldMatrix.version;
				_localToView_viewVersion	= viewMatrix.version;
			}

			return _localToView;
		}

		public function get localToScreen() : Matrix4x4
		{
			var localToViewMatrix	: Matrix4x4 = localToView;
			var projectionMatrix	: Matrix4x4 = projection;

			if (_localToScreen_localToViewVersion != localToViewMatrix.version ||
				_localToScreen_projectionVersion != projectionMatrix.version)
			{
				_localToScreen = Matrix4x4.multiply(projectionMatrix, localToViewMatrix, _localToScreen);
				_localToScreen_localToViewVersion	= localToViewMatrix.version;
				_localToScreen_projectionVersion	= projectionMatrix.version;
			}

			return _localToScreen;
		}

		public function get screentoUv() : Matrix4x4
		{
			return _SCREEN_TO_UV;
		}

		public function get localToUv() : Matrix4x4
		{
			var localToScreenMatrix : Matrix4x4 = localToScreen;
			var screenToUvMatrix	: Matrix4x4 = screentoUv;

			if (_localToUv_localToScreenVersion != localToScreenMatrix.version)
			{
				_localToUv = Matrix4x4.multiply(screenToUvMatrix, localToScreenMatrix);
				_localToUv_localToScreenVersion = localToScreenMatrix.version;
			}

			return _localToUv;
		}

		public function set world(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _world);
		}

		public function set view(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _view);
		}

		public function set projection(value : Matrix4x4) : void
		{
			Matrix4x4.copy(value, _projection);
		}

		public function LocalData()
		{
			_world								= new Matrix4x4();
			_view								= new Matrix4x4();
			_projection							= new Matrix4x4();

			reset();
		}

		public function reset() : void
		{
			_viewInverse_viewVersion			= uint.MAX_VALUE;
			_worldInverse_worldVersion			= uint.MAX_VALUE;
			_localToView_viewVersion			= uint.MAX_VALUE;
			_localToView_worldVersion			= uint.MAX_VALUE;
			_localToScreen_localToViewVersion	= uint.MAX_VALUE;
			_localToScreen_projectionVersion	= uint.MAX_VALUE;
		}
	}
}

Update LocalData class to use cache the same way IWorldData's implementations do


package
{
	import flare.display.TextSprite;

	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.events.TimerEvent;
	import flash.net.URLLoader;
	import flash.utils.Timer;

	public class ProgressBar extends Sprite
	{
		private var _backColor:uint;
		private var _fillColor:uint;
		private var _barWidth:Number;
		private var _barHeight:Number;
		private var _msg:TextSprite;

		private var _bar:Sprite;
		private var _back:Shape;
		private var _fill:Shape;
		private var _progress:Number = 0;

		public function get progress():Number { return _progress; }
		public function set progress(v:Number):void {
			v = isNaN(v) ? 0 : v;
			_progress = v;
			_fill.graphics.clear();
			_fill.graphics.beginFill(_fillColor);
			_fill.graphics.drawRoundRect(0, 0, v*_barWidth,
				_barHeight, _barHeight, _barHeight);
		}

		public function get bar():Sprite { return _bar; }
		public function get message():TextSprite { return _msg; }

		public function ProgressBar(message:String="LOADING", w:Number=200,
			h:Number=6, fillColor:uint=0xff3333, backColor:uint=0xcccccc)
		{
			_fillColor = fillColor;
			_backColor = backColor;
			_barWidth = w;
			_barHeight = h;

			addChild(_bar = new Sprite());
			addChild(_msg = new TextSprite(message));

			_bar.addChild(_back = new Shape());
			_bar.addChild(_fill = new Shape());

			_back.graphics.beginFill(_backColor);
			_back.graphics.drawRoundRect(0, 0, _barWidth,
				_barHeight, _barHeight, _barHeight);

			_msg.font = "Verdana";
			_msg.size = 18;
			_msg.color = _fillColor;
			_msg.letterSpacing = 2;
			_msg.y = 1.5 * _barHeight;
		}

		public function loadURL(ldr:URLLoader,
			onComplete:Function=null, onError:Function=null):URLLoader
		{
			var bar:ProgressBar = this;
			ldr.addEventListener(Event.COMPLETE, function(evt:Event):void {
            	this.progress = 1; // set progress bar to complete
            	var timer:Timer = new Timer(1000);
            	timer.addEventListener(TimerEvent.TIMER, function(e:Event):void
            	{
            		timer.stop(); timer = null;
            		try {
	            		if (onComplete!=null) onComplete();
	             	} catch (err:Error) {
	             		error(err);
	             		return;
	             	}
            		// remove progress bar
            		if (parent) parent.removeChild(bar);
            	});
				timer.start();
            });
            ldr.addEventListener(ProgressEvent.PROGRESS,
            	function(evt:ProgressEvent):void {
            		bar.progress = evt.bytesLoaded / evt.bytesTotal;
            	}
            );
            var error:Function = function(e:Object=null):void {
            	bar.message.text = "FAILED";
            	trace(e.toString());
            	if (onError!=null) onError();
            };
            ldr.addEventListener(IOErrorEvent.IO_ERROR, error);
            ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
            return ldr;
		}

	} // end of class ProgressBar
}

package
{
	import flare.display.TextSprite;

	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.events.TimerEvent;
	import flash.net.URLLoader;
	import flash.utils.Timer;

	public class ProgressBar extends Sprite
	{
		private var _backColor:uint;
		private var _fillColor:uint;
		private var _barWidth:Number;
		private var _barHeight:Number;
		private var _msg:TextSprite;

		private var _bar:Sprite;
		private var _back:Shape;
		private var _fill:Shape;
		private var _progress:Number = 0;

		public function get progress():Number { return _progress; }
		public function set progress(v:Number):void {
			v = isNaN(v) ? 0 : v;
			_progress = v;
			_fill.graphics.clear();
			_fill.graphics.beginFill(_fillColor);
			_fill.graphics.drawRoundRect(0, 0, v*_barWidth,
				_barHeight, _barHeight, _barHeight);
		}

		public function get bar():Sprite { return _bar; }
		public function get message():TextSprite { return _msg; }

		public function ProgressBar(message:String="LOADING", w:Number=200,
			h:Number=6, fillColor:uint=0xff3333, backColor:uint=0xcccccc)
		{
			_fillColor = fillColor;
			_backColor = backColor;
			_barWidth = w;
			_barHeight = h;

			addChild(_bar = new Sprite());
			addChild(_msg = new TextSprite(message));

			_bar.addChild(_back = new Shape());
			_bar.addChild(_fill = new Shape());

			_back.graphics.beginFill(_backColor);
			_back.graphics.drawRoundRect(0, 0, _barWidth,
				_barHeight, _barHeight, _barHeight);

			_msg.font = "Verdana";
			_msg.size = 18;
			_msg.color = _fillColor;
			_msg.letterSpacing = 2;
			_msg.y = 1.5 * _barHeight;
		}

		public function loadURL(ldr:URLLoader,
			onComplete:Function=null, onError:Function=null):URLLoader
		{
			var bar:ProgressBar = this;
			ldr.addEventListener(Event.COMPLETE, function(evt:Event):void {
            	this.progress = 1; // set progress bar to complete
            	var timer:Timer = new Timer(1000);

            	timer.addEventListener(TimerEvent.TIMER, function(e:Event):void
            	{
            		timer.stop(); timer = null;
            		try {
	            		if (onComplete!=null) onComplete();
	             	} catch (err:Error) {
            			var stack_Trace:String = err.getStackTrace();
	             		error(err);
	             		return;
	             	}
            		// remove progress bar
            		if (parent) parent.removeChild(bar);
            	});
				timer.start();
            });
            ldr.addEventListener(ProgressEvent.PROGRESS,
            	function(evt:ProgressEvent):void {
            		bar.progress = evt.bytesLoaded / evt.bytesTotal;
            	}
            );
            var error:Function = function(e:Object=null):void {
            	bar.message.text = "FAILED";
            	trace(e.toString());
            	if (onError!=null) onError();
            };
            ldr.addEventListener(IOErrorEvent.IO_ERROR, error);
            ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error);
            return ldr;
		}

	} // end of class ProgressBar
}

Add error message.

Add error message.


package widgets.supportClasses
{

import com.esri.ags.FeatureSet;
import com.esri.ags.Graphic;
import com.esri.ags.layers.FeatureLayer;
import com.esri.ags.layers.supportClasses.CodedValue;
import com.esri.ags.layers.supportClasses.CodedValueDomain;
import com.esri.ags.layers.supportClasses.FeatureType;
import com.esri.ags.layers.supportClasses.Field;
import com.esri.ags.layers.supportClasses.LayerDetails;

import mx.core.FlexGlobals;
import mx.core.LayoutDirection;
import mx.formatters.DateFormatter;

[Bindable]
public class ResultAttributes
{
    public var attributes:Object;
    public var title:String;
    public var content:String;
    public var link:String;
    public var linkAlias:String;

    public static function toResultAttributes(fields:XMLList,
                                              graphic:Graphic = null,
                                              featureSet:FeatureSet = null,
                                              layer:FeatureLayer = null,
                                              layerDetails:LayerDetails = null,
                                              fallbackTitle:String = null,
                                              titleField:String = null,
                                              linkField:String = null,
                                              linkAlias:String = null):ResultAttributes
    {
        var resultAttributes:ResultAttributes = new ResultAttributes;

        var value:String = "";
        var title:String = "";
        var content:String = "";
        var link:String = "";
        var linkAlias:String;

        var fieldsXMLList:XMLList = fields ? fields.field : null;
        if (fields && fields[0].@all[0] == "true")
        {
            if (layerDetails.fields)
            {
                for each (var field:Field in layerDetails.fields)
                {
                    if (field.name in graphic.attributes)
                    {
                        displayFields(field.name, getFieldXML(field.name, fieldsXMLList), field);
                    }
                }
            }
            else
            {
                for (var fieldName:String in graphic.attributes)
                {
                    displayFields(fieldName, getFieldXML(fieldName, fieldsXMLList), null);
                }
            }
        }
        else
        {
            for each (var fieldXML:XML in fieldsXMLList) // display the fields in the same order as specified
            {
                if (fieldXML.@name[0] in graphic.attributes)
                {
                    displayFields(fieldXML.@name[0], fieldXML, getField(layer, fieldXML.@name[0]));
                }
            }
        }

        resultAttributes.attributes = graphic.attributes;
        resultAttributes.title = title ? title : fallbackTitle;
        resultAttributes.content = content.replace(/\n$/, '');
        resultAttributes.link = link ? link : null;
        resultAttributes.linkAlias = linkAlias;

        function displayFields(fieldName:String, fieldXML:XML, field:Field):void
        {
            var fieldNameTextValue:String = graphic.attributes[fieldName];
            value = fieldNameTextValue ? fieldNameTextValue : "";

            if (value)
            {
                var isDateField:Boolean;
                var useUTC:Boolean;
                var dateFormat:String;
                if (fieldXML)
                {
                    useUTC = fieldXML.format.@useutc[0] || fieldXML.@useutc[0] == "true";
                    dateFormat = fieldXML.format.@dateformat[0] || fieldXML.@dateformat[0];
                    if (dateFormat)
                    {
                        isDateField = true;
                    }
                }
                if (!isDateField && field)
                {
                    isDateField = field.type == Field.TYPE_DATE;
                }
                if (isDateField)
                {
                    var dateMS:Number = Number(value);
                    if (!isNaN(dateMS))
                    {
                        value = msToDate(dateMS, dateFormat, useUTC);
                    }
                }
                else
                {
                    var typeID:String = layerDetails.typeIdField ? graphic.attributes[layerDetails.typeIdField] : null;
                    if (fieldName == layerDetails.typeIdField)
                    {
                        var featureType:FeatureType = getFeatureType(layer, typeID);
                        if (featureType && featureType.name)
                        {
                            value = featureType.name;
                        }
                    }
                    else
                    {
                        var codedValue:CodedValue = getCodedValue(layer, fieldName, value, typeID);
                        if (codedValue)
                        {
                            value = codedValue.name;
                        }
                    }
                }
            }

            if (titleField && fieldName.toUpperCase() == titleField.toUpperCase())
            {
                title = value;
            }
            else if (linkField && fieldName.toUpperCase() == linkField.toUpperCase())
            {
                link = value;
                linkAlias = linkAlias;
            }
            else if (fieldName.toUpperCase() != "SHAPE_LENGTH" && fieldName.toUpperCase() != "SHAPE_AREA")
            {
                var fieldLabel:String;

                if (fieldXML && fieldXML.@alias[0])
                {
                    fieldLabel = fieldXML.@alias[0];
                }
                else
                {
                    fieldLabel = featureSet.fieldAliases[fieldName];
                }

                if (FlexGlobals.topLevelApplication.layoutDirection == LayoutDirection.RTL)
                {
                    content += value + " :" + fieldLabel + "\n";
                }
                else
                {
                    content += fieldLabel + ": " + value + "\n";
                }
            }
        }

        return resultAttributes;
    }

    private static function getFieldXML(fieldName:String, fields:XMLList):XML
    {
        var result:XML;

        for each (var fieldXML:XML in fields)
        {
            if (fieldName == fieldXML.@name[0])
            {
                result = fieldXML;
                break;
            }
        }

        return result;
    }

    private static function getField(layer:FeatureLayer, fieldName:String):Field
    {
        var result:Field;

        if (layer)
        {
            for each (var field:Field in layer.layerDetails.fields)
            {
                if (fieldName == field.name)
                {
                    result = field;
                    break;
                }
            }
        }

        return result;
    }

    private static function getFeatureType(layer:FeatureLayer, typeID:String):FeatureType
    {
        var result:FeatureType;

        if (layer)
        {
            for each (var featureType:FeatureType in layer.layerDetails.types)
            {
                if (typeID == featureType.id)
                {
                    result = featureType;
                    break;
                }
            }
        }

        return result;
    }

    private static function msToDate(ms:Number, dateFormat:String, useUTC:Boolean):String
    {
        var date:Date = new Date(ms);
        if (date.milliseconds == 999) // workaround for REST bug
        {
            date.milliseconds++;
        }
        if (useUTC)
        {
            date.minutes += date.timezoneOffset;
        }

        if (dateFormat)
        {
            var dateFormatter:DateFormatter = new DateFormatter();
            dateFormatter.formatString = dateFormat;
            var result:String = dateFormatter.format(date);
            if (result)
            {
                return result;
            }
            else
            {
                return dateFormatter.error;
            }
        }
        else
        {
            return date.toLocaleString();
        }
    }

    private static function getCodedValue(layer:FeatureLayer, fieldName:String, fieldValue:String, typeID:String):CodedValue
    {
        var result:CodedValue;

        var codedValueDomain:CodedValueDomain;
        if (typeID)
        {
            var featureType:FeatureType = getFeatureType(layer, typeID);
            if (featureType)
            {
                codedValueDomain = featureType.domains[fieldName] as CodedValueDomain;
            }
        }
        else
        {
            var field:Field = getField(layer, fieldName);
            if (field)
            {
                codedValueDomain = field.domain as CodedValueDomain;
            }
        }

        if (codedValueDomain)
        {
            for each (var codedValue:CodedValue in codedValueDomain.codedValues)
            {
                if (fieldValue == codedValue.code)
                {
                    result = codedValue;
                    break;
                }
            }
        }

        return result;
    }
}

}

package widgets.supportClasses
{

import com.esri.ags.FeatureSet;
import com.esri.ags.Graphic;
import com.esri.ags.layers.FeatureLayer;
import com.esri.ags.layers.supportClasses.CodedValue;
import com.esri.ags.layers.supportClasses.CodedValueDomain;
import com.esri.ags.layers.supportClasses.FeatureType;
import com.esri.ags.layers.supportClasses.Field;
import com.esri.ags.layers.supportClasses.LayerDetails;

import mx.core.FlexGlobals;
import mx.core.LayoutDirection;
import mx.formatters.DateFormatter;

[Bindable]
public class ResultAttributes
{
    public var attributes:Object;
    public var title:String;
    public var content:String;
    public var link:String;
    public var linkAlias:String;

    public static function toResultAttributes(fields:XMLList,
                                              graphic:Graphic = null,
                                              featureSet:FeatureSet = null,
                                              layer:FeatureLayer = null,
                                              layerDetails:LayerDetails = null,
                                              fallbackTitle:String = null,
                                              titleField:String = null,
                                              linkField:String = null,
                                              linkAlias:String = null):ResultAttributes
    {
        var resultAttributes:ResultAttributes = new ResultAttributes;

        var value:String = "";
        var title:String = "";
        var content:String = "";
        var link:String = "";
        var linkAlias:String;

        var fieldsXMLList:XMLList = fields ? fields.field : null;
        if (fields && fields[0].@all[0] == "true")
        {
            if (layerDetails.fields)
            {
                for each (var field:Field in layerDetails.fields)
                {
                    if (field.name in graphic.attributes)
                    {
                        displayFields(field.name, getFieldXML(field.name, fieldsXMLList), field);
                    }
                }
            }
            else
            {
                for (var fieldName:String in graphic.attributes)
                {
                    displayFields(fieldName, getFieldXML(fieldName, fieldsXMLList), null);
                }
            }
        }
        else
        {
            for each (var fieldXML:XML in fieldsXMLList) // display the fields in the same order as specified
            {
                if (fieldXML.@name[0] in graphic.attributes)
                {
                    displayFields(fieldXML.@name[0], fieldXML, getField(layer, fieldXML.@name[0]));
                }
            }
        }

        resultAttributes.attributes = graphic.attributes;
        resultAttributes.title = title ? title : fallbackTitle;
        resultAttributes.content = content.replace(/\n$/, '');
        resultAttributes.link = link ? link : null;
        resultAttributes.linkAlias = linkAlias;

        function displayFields(fieldName:String, fieldXML:XML, field:Field):void
        {
            var fieldNameTextValue:String = graphic.attributes[fieldName];
            value = fieldNameTextValue ? fieldNameTextValue : "";

            if (value)
            {
                var isDateField:Boolean;
                var useUTC:Boolean;
                var dateFormat:String;
                if (fieldXML)
                {
                    useUTC = fieldXML.format.@useutc[0] == "true" || fieldXML.@useutc[0] == "true";
                    dateFormat = fieldXML.format.@dateformat[0] || fieldXML.@dateformat[0];
                    if (dateFormat)
                    {
                        isDateField = true;
                    }
                }
                if (!isDateField && field)
                {
                    isDateField = field.type == Field.TYPE_DATE;
                }
                if (isDateField)
                {
                    var dateMS:Number = Number(value);
                    if (!isNaN(dateMS))
                    {
                        value = msToDate(dateMS, dateFormat, useUTC);
                    }
                }
                else
                {
                    var typeID:String = layerDetails.typeIdField ? graphic.attributes[layerDetails.typeIdField] : null;
                    if (fieldName == layerDetails.typeIdField)
                    {
                        var featureType:FeatureType = getFeatureType(layer, typeID);
                        if (featureType && featureType.name)
                        {
                            value = featureType.name;
                        }
                    }
                    else
                    {
                        var codedValue:CodedValue = getCodedValue(layer, fieldName, value, typeID);
                        if (codedValue)
                        {
                            value = codedValue.name;
                        }
                    }
                }
            }

            if (titleField && fieldName.toUpperCase() == titleField.toUpperCase())
            {
                title = value;
            }
            else if (linkField && fieldName.toUpperCase() == linkField.toUpperCase())
            {
                link = value;
                linkAlias = linkAlias;
            }
            else if (fieldName.toUpperCase() != "SHAPE_LENGTH" && fieldName.toUpperCase() != "SHAPE_AREA")
            {
                var fieldLabel:String;

                if (fieldXML && fieldXML.@alias[0])
                {
                    fieldLabel = fieldXML.@alias[0];
                }
                else
                {
                    fieldLabel = featureSet.fieldAliases[fieldName];
                }

                if (FlexGlobals.topLevelApplication.layoutDirection == LayoutDirection.RTL)
                {
                    content += value + " :" + fieldLabel + "\n";
                }
                else
                {
                    content += fieldLabel + ": " + value + "\n";
                }
            }
        }

        return resultAttributes;
    }

    private static function getFieldXML(fieldName:String, fields:XMLList):XML
    {
        var result:XML;

        for each (var fieldXML:XML in fields)
        {
            if (fieldName == fieldXML.@name[0])
            {
                result = fieldXML;
                break;
            }
        }

        return result;
    }

    private static function getField(layer:FeatureLayer, fieldName:String):Field
    {
        var result:Field;

        if (layer)
        {
            for each (var field:Field in layer.layerDetails.fields)
            {
                if (fieldName == field.name)
                {
                    result = field;
                    break;
                }
            }
        }

        return result;
    }

    private static function getFeatureType(layer:FeatureLayer, typeID:String):FeatureType
    {
        var result:FeatureType;

        if (layer)
        {
            for each (var featureType:FeatureType in layer.layerDetails.types)
            {
                if (typeID == featureType.id)
                {
                    result = featureType;
                    break;
                }
            }
        }

        return result;
    }

    private static function msToDate(ms:Number, dateFormat:String, useUTC:Boolean):String
    {
        var date:Date = new Date(ms);
        if (date.milliseconds == 999) // workaround for REST bug
        {
            date.milliseconds++;
        }
        if (useUTC)
        {
            date.minutes += date.timezoneOffset;
        }

        if (dateFormat)
        {
            var dateFormatter:DateFormatter = new DateFormatter();
            dateFormatter.formatString = dateFormat;
            var result:String = dateFormatter.format(date);
            if (result)
            {
                return result;
            }
            else
            {
                return dateFormatter.error;
            }
        }
        else
        {
            return date.toLocaleString();
        }
    }

    private static function getCodedValue(layer:FeatureLayer, fieldName:String, fieldValue:String, typeID:String):CodedValue
    {
        var result:CodedValue;

        var codedValueDomain:CodedValueDomain;
        if (typeID)
        {
            var featureType:FeatureType = getFeatureType(layer, typeID);
            if (featureType)
            {
                codedValueDomain = featureType.domains[fieldName] as CodedValueDomain;
            }
        }
        else
        {
            var field:Field = getField(layer, fieldName);
            if (field)
            {
                codedValueDomain = field.domain as CodedValueDomain;
            }
        }

        if (codedValueDomain)
        {
            for each (var codedValue:CodedValue in codedValueDomain.codedValues)
            {
                if (fieldValue == codedValue.code)
                {
                    result = codedValue;
                    break;
                }
            }
        }

        return result;
    }
}

}

Fix ResultAttributes useUTC assignment.

Fix ResultAttributes useUTC assignment.