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

	import org.apache.flex.core.ILayoutChild;
    import org.apache.flex.core.IStrand;
    import org.apache.flex.core.UIMetrics;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;
    import org.apache.flex.utils.BeadMetrics;

    /**
     *  The TextInputView class is the view for
     *  the org.apache.flex.html.TextInput in
     *  a ComboBox and other controls
     *  because it does not display a border.
     *  It displays text using a TextField, so there is no
     *  right-to-left text support in this view.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class TextInputView extends TextFieldViewBase
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function TextInputView()
		{
			super();

			textField.selectable = true;
			textField.type = TextFieldType.INPUT;
			textField.mouseEnabled = true;
			textField.multiline = false;
			textField.wordWrap = false;
		}

        /**
         *  @private
         */
		override public function set strand(value:IStrand):void
		{
			super.strand = value;

            var w:Number;
            var h:Number;
            var ilc:ILayoutChild = host as ILayoutChild;
            if (ilc.isWidthSizedToContent())
            {
                // use default width of 20
                var s:String = textField.text;
                textField.text = "0";
                w = textField.textWidth * 20;
                h = textField.textHeight;
                textField.text = s;
                ilc.setWidth(w, true);
            }
            if (ilc.isHeightSizedToContent())
            {
                var uiMetrics:UIMetrics = BeadMetrics.getMetrics(host);
                if (isNaN(h))
                {
                    s = textField.text;
                    textField.text = "0";
                    h = textField.textHeight;
                    textField.text = s;
                }
                ilc.setHeight(h + uiMetrics.top + uiMetrics.bottom, true);
            }

			IEventDispatcher(host).addEventListener("widthChanged", sizeChangedHandler);
			IEventDispatcher(host).addEventListener("heightChanged", sizeChangedHandler);
			sizeChangedHandler(null);
		}

		private function sizeChangedHandler(event:Event):void
		{
			var ww:Number = host.width;
			if( !isNaN(ww) && ww > 0 ) textField.width = ww;

			var hh:Number = host.height;
			if( !isNaN(hh) && hh > 0 )
            {
                textField.height = textField.textHeight + 5;
            }

            textField.y = ((hh - textField.height) / 2);
		}
	}
}

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

	import org.apache.flex.core.ILayoutChild;
    import org.apache.flex.core.IStrand;
    import org.apache.flex.core.UIMetrics;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.IEventDispatcher;
    import org.apache.flex.utils.BeadMetrics;

    /**
     *  The TextInputView class is the view for
     *  the org.apache.flex.html.TextInput in
     *  a ComboBox and other controls
     *  because it does not display a border.
     *  It displays text using a TextField, so there is no
     *  right-to-left text support in this view.
     *
     *  @langversion 3.0
     *  @playerversion Flash 10.2
     *  @playerversion AIR 2.6
     *  @productversion FlexJS 0.0
     */
	public class TextInputView extends TextFieldViewBase
	{
        /**
         *  Constructor.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function TextInputView()
		{
			super();

			textField.selectable = true;
			textField.type = TextFieldType.INPUT;
			textField.mouseEnabled = true;
			textField.multiline = false;
			textField.wordWrap = false;
		}

        /**
         *  @private
         */
		override public function set strand(value:IStrand):void
		{
			super.strand = value;

            var w:Number;
            var h:Number;
            var uiMetrics:UIMetrics;
            var ilc:ILayoutChild = host as ILayoutChild;
            if (ilc.isWidthSizedToContent())
            {
                uiMetrics = BeadMetrics.getMetrics(host);
                // use default width of 20
                var s:String = textField.text;
                textField.text = "0";
                w = textField.textWidth * 20;
                h = textField.textHeight;
                textField.text = s;
                ilc.setWidth(w + uiMetrics.left + uiMetrics.right, true);
            }
            if (ilc.isHeightSizedToContent())
            {
                if (!uiMetrics)
                    uiMetrics = BeadMetrics.getMetrics(host);
                if (isNaN(h))
                {
                    s = textField.text;
                    textField.text = "0";
                    h = textField.textHeight;
                    textField.text = s;
                }
                ilc.setHeight(h + uiMetrics.top + uiMetrics.bottom, true);
            }

			IEventDispatcher(host).addEventListener("widthChanged", sizeChangedHandler);
			IEventDispatcher(host).addEventListener("heightChanged", sizeChangedHandler);
			sizeChangedHandler(null);
		}

		private function sizeChangedHandler(event:Event):void
		{
			var ww:Number = host.width;
			if( !isNaN(ww) && ww > 0 ) textField.width = ww;

			var hh:Number = host.height;
			if( !isNaN(hh) && hh > 0 )
            {
                textField.height = textField.textHeight + 5;
            }

            textField.y = ((hh - textField.height) / 2);
		}
	}
}

adjust default TextInput width

adjust default TextInput width


package aerys.minko.type.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.type.stream.IVertexStream;
	import aerys.minko.type.stream.IndexStream;
	import aerys.minko.type.stream.format.VertexComponent;

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

	/**
	 * VertexIterator allow per-vertex access on VertexStream objects.
	 *
	 * The class overrides the "[]" and "delete" operators and is iterable
	 * using "for" and "for each" loops. It enable an higher level and easier
	 * traversal and manipulation of the underlaying data stream while
	 * minimizing the memory footprint.
	 *
	 * <pre>
	 * public function tracePositions(mesh : IMesh) : void
	 * {
	 * 	var vertices : VertexIterator = new VertexIterator(mesh.vertexStream);
	 *
	 * 	for each (var vertex : VertexReference in vertices)
	 * 		trace(vertex.x, vertex.y, vertex.z);
	 * }
	 * </pre>
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public class VertexIterator extends Proxy
	{
		use namespace minko_stream;

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

		private var _singleReference	: Boolean			= true;

		private var _vertex				: VertexReference	= null;
		private var _vstream			: IVertexStream		= null;
		private var _istream			: IndexStream		= null;

		private var _propertyToStream	: Object			= new Object();

		public function get length() : int
		{
			return _istream ? _istream.length : _vstream.length;
		}

		/**
		 * Create a new VertexIterator instance.
		 *
		 * If the "singleReference" argument is true, only one VertexReference
		 * will be created during a "for each" loop on the iterator. This
		 * VertexReference will be updated at each iteration to provide
		 * the data of the current vertex. Otherwise, a dedicated
		 * VertexReference will be provided at each iteration. Using the
		 * "single reference" mode is nicer on the memory footprint, but makes
		 * it impossible to keep a VertexReference object and re-use it later
		 * as it will be automatically updated at each iteration.
		 *
		 * @param vertexStream The VertexStream to use.
		 *
		 * @param indexStream The IndexStream to use. If none is
		 * provided, the iterator will iterate on each vertex of the
		 * VertexStream. Otherwise, the iterator will iterate
		 * on vertices as provided by the indices in the IndexStream.
		 *
		 * @param shallow Whether to use the "single reference" mode.
		 *
		 * @return
		 *
		 */
		public function VertexIterator(vertexStream		: IVertexStream,
									   indexStream		: IndexStream 	= null,
									   singleReference	: Boolean		= true)
		{
			super();

			/*if (!vertexStream.dynamic)
				throw new Error("Unable to work on static VertexStream.");
			if (!indexStream.dynamic)
				throw new Error("Unable to work on static IndexStream.");*/

			_vstream = vertexStream;
			_istream = indexStream;
			_singleReference = singleReference;

			initialize();
		}

		private function initialize() : void
		{
			var components : Object = _vstream.format.components;

			for each (var component : VertexComponent in components)
				for each (var field : String in component.fields)
					_propertyToStream[field] = _vstream.getSubStreamByComponent(component);
		}

		override flash_proxy function getProperty(name : *) : *
		{
			var index : int = int(name);

			if (_istream)
				index = _istream._data[index];

			var vertex : VertexReference	= new VertexReference(_vstream, index);

			vertex._propertyToStream = _propertyToStream;

			return vertex;
		}

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

			if (_vstream.deleteVertexByIndex(index))
			{
				if (index <= _index)
					++_offset;

				return true;
			}

			return false;
		}

		override flash_proxy function hasProperty(name : *) : Boolean
		{
			var index : int = int(name);

			return _istream
				   ? index < _istream.length
				   : index < _vstream.length;
		}

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

			return _istream
				   ? index < _istream.length ? index + 1 : 0
				   : index < _vstream.length ? index + 1 : 0;
		}

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

		override flash_proxy function nextValue(index : int) : *
		{
			_index = index - 1;
			index = _istream ? _istream._data[_index] : _index;

			if (!_singleReference || !_vertex)
			{
				_vertex = new VertexReference(_vstream, index);
				_vertex._propertyToStream = _propertyToStream;
			}

			if (_singleReference)
				_vertex._index = -_offset + index;

			return _vertex;
		}
	}
}

package aerys.minko.type.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.type.stream.IVertexStream;
	import aerys.minko.type.stream.IndexStream;
	import aerys.minko.type.stream.format.VertexComponent;

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

	/**
	 * VertexIterator allow per-vertex access on VertexStream objects.
	 *
	 * The class overrides the "[]" and "delete" operators and is iterable
	 * using "for" and "for each" loops. It enable an higher level and easier
	 * traversal and manipulation of the underlaying data stream while
	 * minimizing the memory footprint.
	 *
	 * <pre>
	 * public function tracePositions(mesh : IMesh) : void
	 * {
	 * 	var vertices : VertexIterator = new VertexIterator(mesh.vertexStream);
	 *
	 * 	for each (var vertex : VertexReference in vertices)
	 * 		trace(vertex.x, vertex.y, vertex.z);
	 * }
	 * </pre>
	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public class VertexIterator extends Proxy
	{
		use namespace minko_stream;

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

		private var _singleReference	: Boolean			= true;

		private var _vertex				: VertexReference	= null;
		private var _vstream			: IVertexStream		= null;
		private var _istream			: IndexStream		= null;

		private var _propertyToStream	: Object			= new Object();

		public function get length() : int
		{
			return _istream ? _istream.length : _vstream.length;
		}

		/**
		 * Create a new VertexIterator instance.
		 *
		 * If the "singleReference" argument is true, only one VertexReference
		 * will be created during a "for each" loop on the iterator. This
		 * VertexReference will be updated at each iteration to provide
		 * the data of the current vertex. Otherwise, a dedicated
		 * VertexReference will be provided at each iteration. Using the
		 * "single reference" mode is nicer on the memory footprint, but makes
		 * it impossible to keep a VertexReference object and re-use it later
		 * as it will be automatically updated at each iteration.
		 *
		 * @param vertexStream The VertexStream to use.
		 *
		 * @param indexStream The IndexStream to use. If none is
		 * provided, the iterator will iterate on each vertex of the
		 * VertexStream. Otherwise, the iterator will iterate
		 * on vertices as provided by the indices in the IndexStream.
		 *
		 * @param shallow Whether to use the "single reference" mode.
		 *
		 * @return
		 *
		 */
		public function VertexIterator(vertexStream		: IVertexStream,
									   indexStream		: IndexStream 	= null,
									   singleReference	: Boolean		= true)
		{
			super();

//			if (!vertexStream.dynamic)
//				throw new Error("Unable to work on static VertexStream.");
//			if (!indexStream.dynamic)
//				throw new Error("Unable to work on static IndexStream.");

			_vstream = vertexStream;
			_istream = indexStream;
			_singleReference = singleReference;

			initialize();
		}

		private function initialize() : void
		{
			var components : Object = _vstream.format.components;

			for each (var component : VertexComponent in components)
				for each (var field : String in component.fields)
					_propertyToStream[field] = _vstream.getSubStreamByComponent(component);
		}

		override flash_proxy function getProperty(name : *) : *
		{
			var index : int = int(name);

			if (_istream)
				index = _istream._data[index];

			var vertex : VertexReference	= new VertexReference(_vstream, index);

			vertex._propertyToStream = _propertyToStream;

			return vertex;
		}

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

			if (_vstream.deleteVertexByIndex(index))
			{
				if (index <= _index)
					++_offset;

				return true;
			}

			return false;
		}

		override flash_proxy function hasProperty(name : *) : Boolean
		{
			var index : int = int(name);

			return _istream
				   ? index < _istream.length
				   : index < _vstream.length;
		}

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

			return _istream
				   ? index < _istream.length ? index + 1 : 0
				   : index < _vstream.length ? index + 1 : 0;
		}

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

		override flash_proxy function nextValue(index : int) : *
		{
			_index = index - 1;
			index = _istream ? _istream._data[_index] : _index;

			if (!_singleReference || !_vertex)
			{
				_vertex = new VertexReference(_vstream, index);
				_vertex._propertyToStream = _propertyToStream;
			}

			if (_singleReference)
				_vertex._index = -_offset + index;

			return _vertex;
		}
	}
}

Resolve conflict

Resolve conflict


////////////////////////////////////////////////////////////////////////////////
//
//  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.accessories
{
	import org.apache.flex.core.IBeadModel;
	import org.apache.flex.core.IFormatBead;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.EventDispatcher;
	import org.apache.flex.events.IEventDispatcher;

	/**
	 * The CurrencyFormatter class formats a value in separated groups. The formatter listens
	 * to a property on a model and when the property changes, formats it and dispatches a
	 * formatChanged event.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class CurrencyFormatter extends EventDispatcher implements IFormatBead
	{
		/**
		 *  constructor
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function CurrencyFormatter()
		{
			super();
		}

		private var _strand:IStrand;

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

			// Listen for the beadsAdded event which signals when all of a strand's
			// beads have been added.
			IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded);
		}

		/**
		 * @private
		 */
		private function handleBeadsAdded(event:Event):void
		{
			// Listen for the change in the model
			var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
			model.addEventListener(eventName,propertyChangeHandler);
			model.addEventListener(propertyName+"Change",propertyChangeHandler);

			// format the current value of that property
			propertyChangeHandler(null);
		}

		private var _propertyName:String;
		private var _eventName:String;
		private var _formattedResult:String;
		private var _fractionalDigits:Number = 2;
        private var _currencySymbol:String = "$";

		/**
		 *  The name of the property on the model to format.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get propertyName():String
		{
			if (_propertyName == null) {
				return "text";
			}
			return _propertyName;
		}
		public function set propertyName(value:String):void
		{
			_propertyName = value;
		}

		/**
		 *  The event dispatched by the model when the property changes. The
		 *  default is propertyName+"Changed".
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get eventName():String
		{
			if (_eventName == null) {
				return _propertyName+"Changed";
			}
			return _eventName;
		}
		public function set eventName(value:String):void
		{
			_eventName = value;
		}

        /**
		 *  Number of digits after the decimal separator
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get fractionalDigits():int
		{
			return _fractionalDigits;
		}
		public function set fractionalDigits(value:int):void
		{
            _fractionalDigits = value;
		}

        /**
         *  The currency symbol, such as "$"
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get currencySymbol():String
        {
            return _currencySymbol;
        }
        public function set currencySymbol(value:String):void
        {
            _currencySymbol = value;
        }

        /**
		 *  The formatted string.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get formattedString():String
		{
			return _formattedResult;
		}

		/**
		 * @private
		 */
		private function propertyChangeHandler(event:Event):void
		{
			// When the property changes, fetch it from the model and
			// format it, storing the result in _formattedResult.
			var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
			var value:Object = model[propertyName];
			_formattedResult = format(value);

			// Dispatch the formatChanged event so any bead that's interested in
			// the formatted string knows to use it.
			var newEvent:Event = new Event("formatChanged");
			this.dispatchEvent(newEvent);
		}

        /**
         *  Computes the formatted string.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function format(value:Object):String
		{
			if (value == null) return "";

			var num:Number = Number(value);
            var source:String = num.toPrecision(fractionalDigits);

			return currencySymbol + source;
		}
	}
}

////////////////////////////////////////////////////////////////////////////////
//
//  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.accessories
{
	import org.apache.flex.core.IBeadModel;
	import org.apache.flex.core.IFormatBead;
	import org.apache.flex.core.IStrand;
	import org.apache.flex.events.Event;
	import org.apache.flex.events.EventDispatcher;
	import org.apache.flex.events.IEventDispatcher;

	/**
	 * The CurrencyFormatter class formats a value in separated groups. The formatter listens
	 * to a property on a model and when the property changes, formats it and dispatches a
	 * formatChanged event.
	 *
	 *  @langversion 3.0
	 *  @playerversion Flash 10.2
	 *  @playerversion AIR 2.6
	 *  @productversion FlexJS 0.0
	 */
	public class CurrencyFormatter extends EventDispatcher implements IFormatBead
	{
		/**
		 *  constructor
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function CurrencyFormatter()
		{
			super();
		}

		private var _strand:IStrand;

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

			// Listen for the beadsAdded event which signals when all of a strand's
			// beads have been added.
			IEventDispatcher(value).addEventListener("beadsAdded",handleBeadsAdded);
		}

		/**
		 * @private
		 */
		private function handleBeadsAdded(event:Event):void
		{
			// Listen for the change in the model
			var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
			model.addEventListener(eventName,propertyChangeHandler);
			model.addEventListener(propertyName+"Change",propertyChangeHandler);

			// format the current value of that property
			propertyChangeHandler(null);
		}

		private var _propertyName:String;
		private var _eventName:String;
		private var _formattedResult:String;
		private var _fractionalDigits:Number = 2;
        private var _currencySymbol:String = "$";

		/**
		 *  The name of the property on the model to format.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get propertyName():String
		{
			if (_propertyName == null) {
				return "text";
			}
			return _propertyName;
		}
		public function set propertyName(value:String):void
		{
			_propertyName = value;
		}

		/**
		 *  The event dispatched by the model when the property changes. The
		 *  default is propertyName+"Changed".
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get eventName():String
		{
			if (_eventName == null) {
				return _propertyName+"Changed";
			}
			return _eventName;
		}
		public function set eventName(value:String):void
		{
			_eventName = value;
		}

        /**
		 *  Number of digits after the decimal separator
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get fractionalDigits():int
		{
			return _fractionalDigits;
		}
		public function set fractionalDigits(value:int):void
		{
            _fractionalDigits = value;
		}

        /**
         *  The currency symbol, such as "$"
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
        public function get currencySymbol():String
        {
            return _currencySymbol;
        }
        public function set currencySymbol(value:String):void
        {
            _currencySymbol = value;
        }

        /**
		 *  The formatted string.
		 *
		 *  @langversion 3.0
		 *  @playerversion Flash 10.2
		 *  @playerversion AIR 2.6
		 *  @productversion FlexJS 0.0
		 */
		public function get formattedString():String
		{
			return _formattedResult;
		}

		/**
		 * @private
		 */
		private function propertyChangeHandler(event:Event):void
		{
			// When the property changes, fetch it from the model and
			// format it, storing the result in _formattedResult.
			var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel;
			var value:Object = model[propertyName];
			_formattedResult = format(value);

			// Dispatch the formatChanged event so any bead that's interested in
			// the formatted string knows to use it.
			var newEvent:Event = new Event("formatChanged");
			this.dispatchEvent(newEvent);
		}

        /**
         *  Computes the formatted string.
         *
         *  @langversion 3.0
         *  @playerversion Flash 10.2
         *  @playerversion AIR 2.6
         *  @productversion FlexJS 0.0
         */
		public function format(value:Object):String
		{
			if (value == null) return "";

			var num:Number = Number(value);
            var source:String = num.toFixed(fractionalDigits);

			return currencySymbol + source;
		}
	}
}

fix currencyformatter

fix currencyformatter


package gov.nih.nci.cbiit.casas.components
{

	import fl.core.UIComponent;

	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.utils.Timer;

	import learnmath.mathml.components.MathMLEditor;
	import learnmath.mathml.formula.Constants;
	import learnmath.windows.ConfigManager;

	import mx.controls.Alert;
	import mx.core.IUIComponent;

	import flash.events.TimerEvent;

	public class FormulaEditor extends MathMLEditor
	{
		public function FormulaEditor()
		{
			//duplicate MathMLEditor Constructor
			ConfigManager.urlFonts="./";
			Constants.setUrlFonts("./");
//			ConfigManager.setConfig("disableSave","false");
//			ConfigManager.setConfig("disableOpen","false");
			ConfigManager.disableOpen=new Boolean(false);
			ConfigManager.disableSave=new Boolean(false);
			addEventListener(KeyboardEvent.KEY_DOWN, processKey);
//			mainPannel.name= "NCI Center for Biomedical Informatics & Information Technology - Scientific Algorithm Service";
//			mainPannel.draw();
			return;
		}

//		override protected function createChildren():void
//		{
//			Alert.show("before created by super", mainPannel+"");
//			super.createChildren();
//			Alert.show("created by super", mainPannel+"");
//			mainPannel=null;
//			while (this.numChildren>0)
//			{
//				this.removeChildAt(0);
//			}
//			var _loc_1:*=new MovieClip();
//			var editorW:Number=800;
//			var editorH:Number=500;
//
//			mainPannel = new FormulaPanel(_loc_1, 0,0,editorW, editorH, returnFocus);
//			mainPannel.draw();
//			mainPannel.setMathML("..xx");
//			Alert.show(mainPannel+"", mainPannel.getMathML());
//			var _loc_2:*=new UIComponent();
//			addChild(_loc_2);
//
//			var _loc_3:*=new Timer(100,1);
//			_loc_3.addEventListenr(TimerEvent.TIMER, redrawEditor);
//			_loc_3.start();
//			return;
//		}

		//override private method
		private function redrawEditor(event:TimerEvent):void
		{
			mainPannel.draw();
			if (focusManager!=null)
			{
				focusManager.setFocus(this);
			}
			return;
		}
	}

}

package gov.nih.nci.cbiit.casas.components
{

	import fl.core.UIComponent;

	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;

	import learnmath.mathml.components.MathMLEditor;
	import learnmath.mathml.formula.Constants;
	import learnmath.windows.ConfigManager;
	import learnmath.windows.apps.EditorApp;

	import mx.containers.Canvas;
	import mx.controls.Alert;
	import mx.controls.listClasses.BaseListData;
	import mx.controls.listClasses.IDropInListItemRenderer;
	import mx.controls.listClasses.IListItemRenderer;
	import mx.core.IDataRenderer;
	import mx.core.IFlexModuleFactory;
	import mx.core.IFontContextComponent;
	import mx.core.IUIComponent;
	import mx.managers.IFocusManagerComponent;
	import mx.events.FlexEvent;

	public class FormulaEditor extends MathMLEditor
		//extends Canvas implements IDataRenderer, IDropInListItemRenderer, IListItemRenderer, IFontContextComponent, IFocusManagerComponent
	{
		private var _mathML:String = "";
		var _editorHeight:Number = 500;
//		private var _listData:BaseListData;
		var _editorWidth:Number = 800;
//		public var mainPannel:EditorApp;

		public function FormulaEditor()
		{
			//duplicate MathMLEditor Constructor
			ConfigManager.urlFonts="./";
			Constants.setUrlFonts("./");
//			ConfigManager.setConfig("disableSave","false");
//			ConfigManager.setConfig("disableOpen","false");
			ConfigManager.disableOpen=new Boolean(false);
			ConfigManager.disableSave=new Boolean(false);
			addEventListener(KeyboardEvent.KEY_DOWN, processKey);
			addEventListener(FlexEvent.CREATION_COMPLETE,onCreationComplete) ;
			return;
		}

		private function onCreationComplete(event : FlexEvent):void
		{
//			this.removeAllCh ildren();
//			this.invalidateDisplayList();
//			createCustomButtons();
			mainPannel.name= "NCI Center for Biomedical Informatics & Information Technology - Scientific Algorithm Service";
			var p1:XML =new XML("<math><mrow><mtext>default</mtext><mo selected='true'>×</mo><mtext>0123456789</mtext></mrow>" + "</math>")
			mainPannel.setMathML(p1);
		}

//		private function createCustomButtons() : void
//		{
//			super.createChildren();
//			mainPannel = null;
//			while (this.numChildren > 0)
//			{
//
//				this.removeChildAt(0);
//			}
//			var _loc_1:* = new MovieClip();
//			mainPannel = new EditorApp(_loc_1, 0, 0, _editorWidth, _editorHeight, returnFocus);
//			mainPannel.draw();
//			mainPannel.setMathML(_mathML);
//			var _loc_2:* = new UIComponent();
//			addChild(_loc_2);
//			_loc_2.addChild(_loc_1);
//			var _loc_3:* = new Timer(100, 1);
//			_loc_3.addEventListener(TimerEvent.TIMER, redrawEditor);
//			_loc_3.start();
//			return;
//		}// end function
/**
		override protected function measure() : void
		{
			measuredHeight = editorHeight;
			measuredMinHeight = editorHeight;
			measuredWidth = editorWidth;
			measuredMinWidth = editorWidth;
			return;
		}// end function

		public function get fontContext() : IFlexModuleFactory
		{
			return moduleFactory;
		}
		public function set fontContext(moduleFactory:IFlexModuleFactory) : void
		{
			this.moduleFactory = moduleFactory;
			return;
		}// end function

		public function get listData() : BaseListData
		{
			return _listData;
		}// end function
		public function set listData(value:BaseListData) : void
		{
			_listData = value;
			return;
		}// end function

		public function get mathML() : String
		{
			_mathML = mainPannel.getMathML();
			return _mathML;
		}// end function

		public function set mathML(mathML:String) : void
		{
			_mathML = mathML;
			if (mainPannel != null)
			{
				mainPannel.setMathML(_mathML);
			}
			return;
		}// end function

		public function get editorHeight() : Number
		{
			return _editorHeight;
		}// end function

		public function get editorWidth() : Number
		{
			return _editorWidth;
		}// end function

		public function set editorWidth(w:Number) : void
		{
			this._editorWidth = w;
			width = w;
			invalidateProperties();
			invalidateSize();
			invalidateDisplayList();
			return;
		}// end function

		public function set editorHeight(h:Number) : void
		{
			this._editorHeight = h;
			height = h;
			invalidateProperties();
			invalidateSize();
			invalidateDisplayList();
			return;
		}
*/
		//override private method
		private function redrawEditor(event:TimerEvent):void
		{
			mainPannel.draw();
			if (focusManager!=null)
			{
				focusManager.setFocus(this);
			}
			return;
		}
/**
		public function saveImageOnServer(type:String, compression:int, callbackName:Function) : void
		{
			mainPannel.saveImageOnServer(type, compression, callbackName);
			return;
		}// end function
		public function setConfiguration(key:String, value:String) : void
		{
			ConfigManager.setConfig(key, value);
			return;
		}// end function
		public function viewImageInBrowser(type:String, compression:int) : void
		{
			mainPannel.viewImageInBrowser(type, compression);
			return;
		}// end function
		public function processKey(event:KeyboardEvent) : void
		{
			if (mainPannel == null)
			{
				return;
			}
			mainPannel.processKey(event);
			return;
		}// end function

		public function returnFocus() : void
		{
			if (focusManager != null)
			{
				focusManager.setFocus(this);
			}
			return;
		}// end function

		public function getBase64Image(type:String, precission:int = 100) : String
		{
			return mainPannel.getBase64Image(type, precission);
		}// end function
 */
	}

}

use creationCompletion event

use creationCompletion event

SVN-Revision: 3128


/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mangui.hls {

    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.net.URLLoader;
    import flash.net.URLStream;
    import org.mangui.hls.constant.HLSSeekStates;
    import org.mangui.hls.controller.AudioTrackController;
    import org.mangui.hls.controller.LevelController;
    import org.mangui.hls.event.HLSEvent;
    import org.mangui.hls.loader.AltAudioLevelLoader;
    import org.mangui.hls.loader.LevelLoader;
    import org.mangui.hls.model.AudioTrack;
    import org.mangui.hls.model.Level;
    import org.mangui.hls.playlist.AltAudioTrack;
    import org.mangui.hls.stream.HLSNetStream;
    import org.mangui.hls.stream.StreamBuffer;

    CONFIG::LOGGING {
        import org.mangui.hls.utils.Log;
    }
    /** Class that manages the streaming process. **/
    public class HLS extends EventDispatcher {
        private var _levelLoader : LevelLoader;
        private var _altAudioLevelLoader : AltAudioLevelLoader;
        private var _audioTrackController : AudioTrackController;
        private var _levelController : LevelController;
        private var _streamBuffer : StreamBuffer;
        /** HLS NetStream **/
        private var _hlsNetStream : HLSNetStream;
        /** HLS URLStream/URLLoader **/
        private var _hlsURLStream : Class;
        private var _hlsURLLoader : Class;
        private var _client : Object = {};
        private var _stage : Stage;
        /* level handling */
        private var _level : int;
        /* overrided quality_manual_level level */
        private var _manual_level : int = -1;

        /** Create and connect all components. **/
        public function HLS() {
            _levelLoader = new LevelLoader(this);
            _altAudioLevelLoader = new AltAudioLevelLoader(this);
            _audioTrackController = new AudioTrackController(this);
            _levelController = new LevelController(this);
            _streamBuffer = new StreamBuffer(this, _audioTrackController, _levelController);
            _hlsURLStream = URLStream as Class;
            _hlsURLLoader = URLLoader as Class;
            // default loader
            var connection : NetConnection = new NetConnection();
            connection.connect(null);
            _hlsNetStream = new HLSNetStream(connection, this, _streamBuffer);
            this.addEventListener(HLSEvent.LEVEL_SWITCH, _levelSwitchHandler);
        };

        /** Forward internal errors. **/
        override public function dispatchEvent(event : Event) : Boolean {
            if (event.type == HLSEvent.ERROR) {
                CONFIG::LOGGING {
                    Log.error((event as HLSEvent).error);
                }
                _hlsNetStream.close();
            }

            if (hasEventListener(event.type)) {
                return super.dispatchEvent(event);
            }

            return false;
        }

        private function _levelSwitchHandler(event : HLSEvent) : void {
            _level = event.level;
        };

        public function dispose() : void {
            this.removeEventListener(HLSEvent.LEVEL_SWITCH, _levelSwitchHandler);
            _levelLoader.dispose();
            _altAudioLevelLoader.dispose();
            _audioTrackController.dispose();
            _levelController.dispose();
            _hlsNetStream.dispose_();
            _streamBuffer.dispose();
            _levelLoader = null;
            _altAudioLevelLoader = null;
            _audioTrackController = null;
            _levelController = null;
            _hlsNetStream = null;
            _client = null;
            _stage = null;
            _hlsNetStream = null;
        }

        /** Return index of first quality level referenced in Manifest  **/
        public function get firstLevel() : int {
            return _levelController.firstLevel;
        };

        /** Return the quality level used when starting a fresh playback **/
        public function get startLevel() : int {
            return _levelController.startLevel;
        };

        /*  set the quality level used when starting a fresh playback */
        public function set startLevel(level : int) : void {
            _levelController.startLevel = level;
        };

        /** Return the quality level used after a seek operation **/
        public function get seekLevel() : int {
            return _levelController.seekLevel;
        };

        /** Return the quality level of the currently played fragment **/
        public function get currentLevel() : int {
            return _hlsNetStream.currentLevel;
        };

        /** Return the quality level of the next played fragment **/
        public function get nextLevel() : int {
            return _streamBuffer.nextLevel;
        };

        /** Return the quality level of last loaded fragment **/
        public function get loadLevel() : int {
            return _level;
        };

        /*  instant quality level switch (-1 for automatic level selection) */
        public function set currentLevel(level : int) : void {
            _manual_level = level;
            // don't flush and seek if never seeked or if end of stream
            if(seekState != HLSSeekStates.IDLE) {
                _streamBuffer.flushBuffer();
                _hlsNetStream.seek(position);
            }
        };

        /*  set quality level for next loaded fragment (-1 for automatic level selection) */
        public function set nextLevel(level : int) : void {
            _manual_level = level;
            _streamBuffer.nextLevel = level;
        };

        /*  set quality level for last loaded fragment (-1 for automatic level selection) */
        public function set loadLevel(level : int) : void {
            _manual_level = level;
        };

        /* check if we are in automatic level selection mode */
        public function get autoLevel() : Boolean {
            return (_manual_level == -1);
        };

        /* return manual level */
        public function get manualLevel() : int {
            return _manual_level;
        };

        /** Return the capping/max level value that could be used by automatic level selection algorithm **/
        public function get autoLevelCapping() : int {
            return _levelController.autoLevelCapping;
        }

        /** set the capping/max level value that could be used by automatic level selection algorithm **/
        public function set autoLevelCapping(newLevel : int) : void {
            _levelController.autoLevelCapping = newLevel;
        }

        /** Return a Vector of quality level **/
        public function get levels() : Vector.<Level> {
            return _levelLoader.levels;
        };

        /** Return the current playback position. **/
        public function get position() : Number {
            return _streamBuffer.position;
        };

        /** Return the live main playlist sliding in seconds since previous out of buffer seek(). **/
        public function get liveSlidingMain() : Number {
            return _streamBuffer.liveSlidingMain;
        }

        /** Return the live altaudio playlist sliding in seconds since previous out of buffer seek(). **/
        public function get liveSlidingAltAudio() : Number {
            return _streamBuffer.liveSlidingAltAudio;
        }

        /** Return the current playback state. **/
        public function get playbackState() : String {
            return _hlsNetStream.playbackState;
        };

        /** Return the current seek state. **/
        public function get seekState() : String {
            return _hlsNetStream.seekState;
        };

        /** Return the current watched time **/
        public function get watched() : Number {
            return _hlsNetStream.watched;
        };

        /** Return the total nb of dropped video frames since last call to hls.load() **/
        public function get droppedFrames() : Number {
            return _hlsNetStream.droppedFrames;
        };

        /** Return the type of stream (VOD/LIVE). **/
        public function get type() : String {
            return _levelLoader.type;
        };

        /** Load and parse a new HLS URL **/
        public function load(url : String) : void {
            _level = 0;
            _hlsNetStream.close();
            _levelLoader.load(url);
        };

        /** return HLS NetStream **/
        public function get stream() : NetStream {
            return _hlsNetStream;
        }

        public function get client() : Object {
            return _client;
        }

        public function set client(value : Object) : void {
            _client = value;
        }

        /** get audio tracks list**/
        public function get audioTracks() : Vector.<AudioTrack> {
            return _audioTrackController.audioTracks;
        };

        /** get alternate audio tracks list from playlist **/
        public function get altAudioTracks() : Vector.<AltAudioTrack> {
            return _levelLoader.altAudioTracks;
        };

        /** get index of the selected audio track (index in audio track lists) **/
        public function get audioTrack() : int {
            return _audioTrackController.audioTrack;
        };

        /** select an audio track, based on its index in audio track lists**/
        public function set audioTrack(val : int) : void {
            _audioTrackController.audioTrack = val;
        }

        /* set stage */
        public function set stage(stage : Stage) : void {
            _stage = stage;
            this.dispatchEvent(new HLSEvent(HLSEvent.STAGE_SET));
        }

        /* get stage */
        public function get stage() : Stage {
            return _stage;
        }

        /* set URL stream loader */
        public function set URLstream(urlstream : Class) : void {
            _hlsURLStream = urlstream;
        }

        /* retrieve URL stream loader */
        public function get URLstream() : Class {
            return _hlsURLStream;
        }

        /* set URL stream loader */
        public function set URLloader(urlloader : Class) : void {
            _hlsURLLoader = urlloader;
        }

        /* retrieve URL stream loader */
        public function get URLloader() : Class {
            return _hlsURLLoader;
        }
        /* start/restart playlist/fragment loading.
           this is only effective if MANIFEST_PARSED event has been triggered already */
        public function startLoad() : void {
            if(levels && levels.length) {
                this.dispatchEvent(new HLSEvent(HLSEvent.LEVEL_SWITCH, startLevel));
            }
        }
    }
}

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mangui.hls {

    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.net.URLLoader;
    import flash.net.URLStream;
    import org.mangui.hls.constant.HLSSeekStates;
    import org.mangui.hls.controller.AudioTrackController;
    import org.mangui.hls.controller.LevelController;
    import org.mangui.hls.event.HLSEvent;
    import org.mangui.hls.loader.AltAudioLevelLoader;
    import org.mangui.hls.loader.LevelLoader;
    import org.mangui.hls.model.AudioTrack;
    import org.mangui.hls.model.Level;
    import org.mangui.hls.playlist.AltAudioTrack;
    import org.mangui.hls.stream.HLSNetStream;
    import org.mangui.hls.stream.StreamBuffer;

    CONFIG::LOGGING {
        import org.mangui.hls.utils.Log;
    }
    /** Class that manages the streaming process. **/
    public class HLS extends EventDispatcher {
        private var _levelLoader : LevelLoader;
        private var _altAudioLevelLoader : AltAudioLevelLoader;
        private var _audioTrackController : AudioTrackController;
        private var _levelController : LevelController;
        private var _streamBuffer : StreamBuffer;
        /** HLS NetStream **/
        private var _hlsNetStream : HLSNetStream;
        /** HLS URLStream/URLLoader **/
        private var _hlsURLStream : Class;
        private var _hlsURLLoader : Class;
        private var _client : Object = {};
        private var _stage : Stage;
        /* level handling */
        private var _level : int;
        /* overrided quality_manual_level level */
        private var _manual_level : int = -1;

        /** Create and connect all components. **/
        public function HLS() {
            _levelLoader = new LevelLoader(this);
            _altAudioLevelLoader = new AltAudioLevelLoader(this);
            _audioTrackController = new AudioTrackController(this);
            _levelController = new LevelController(this);
            _streamBuffer = new StreamBuffer(this, _audioTrackController, _levelController);
            _hlsURLStream = URLStream as Class;
            _hlsURLLoader = URLLoader as Class;
            // default loader
            var connection : NetConnection = new NetConnection();
            connection.connect(null);
            _hlsNetStream = new HLSNetStream(connection, this, _streamBuffer);
            this.addEventListener(HLSEvent.LEVEL_SWITCH, _levelSwitchHandler);
        };

        /** Forward internal errors. **/
        override public function dispatchEvent(event : Event) : Boolean {
            if (event.type == HLSEvent.ERROR) {
                CONFIG::LOGGING {
                    Log.error((event as HLSEvent).error);
                }
                _hlsNetStream.close();
            }

            if (hasEventListener(event.type)) {
                return super.dispatchEvent(event);
            }

            return false;
        }

        private function _levelSwitchHandler(event : HLSEvent) : void {
            _level = event.level;
        };

        public function dispose() : void {
            this.removeEventListener(HLSEvent.LEVEL_SWITCH, _levelSwitchHandler);
            _levelLoader.dispose();
            _altAudioLevelLoader.dispose();
            _audioTrackController.dispose();
            _levelController.dispose();
            _hlsNetStream.dispose_();
            _streamBuffer.dispose();
            _levelLoader = null;
            _altAudioLevelLoader = null;
            _audioTrackController = null;
            _levelController = null;
            _hlsNetStream = null;
            _client = null;
            _stage = null;
            _hlsNetStream = null;
        }

        /** Return index of first quality level referenced in Manifest  **/
        public function get firstLevel() : int {
            return _levelController.firstLevel;
        };

        /** Return the quality level used when starting a fresh playback **/
        public function get startLevel() : int {
            return _levelController.startLevel;
        };

        /*  set the quality level used when starting a fresh playback */
        public function set startLevel(level : int) : void {
            _levelController.startLevel = level;
        };

        /** Return the quality level used after a seek operation **/
        public function get seekLevel() : int {
            return _levelController.seekLevel;
        };

        /** Return the quality level of the currently played fragment **/
        public function get currentLevel() : int {
            return _hlsNetStream.currentLevel;
        };

        /** Return the quality level of the next played fragment **/
        public function get nextLevel() : int {
            return _streamBuffer.nextLevel;
        };

        /** Return the quality level of last loaded fragment **/
        public function get loadLevel() : int {
            return _level;
        };

        /*  instant quality level switch (-1 for automatic level selection) */
        public function set currentLevel(level : int) : void {
            _manual_level = level;
            // don't flush and seek if never seeked or if end of stream
            if(seekState != HLSSeekStates.IDLE) {
                _streamBuffer.flushBuffer();
                _hlsNetStream.seek(position);
            }
        };

        /*  set quality level for next loaded fragment (-1 for automatic level selection) */
        public function set nextLevel(level : int) : void {
            _manual_level = level;
            _streamBuffer.nextLevel = level;
        };

        /*  set quality level for next loaded fragment (-1 for automatic level selection) */
        public function set loadLevel(level : int) : void {
            _manual_level = level;
        };

        /* check if we are in automatic level selection mode */
        public function get autoLevel() : Boolean {
            return (_manual_level == -1);
        };

        /* return manual level */
        public function get manualLevel() : int {
            return _manual_level;
        };

        /** Return the capping/max level value that could be used by automatic level selection algorithm **/
        public function get autoLevelCapping() : int {
            return _levelController.autoLevelCapping;
        }

        /** set the capping/max level value that could be used by automatic level selection algorithm **/
        public function set autoLevelCapping(newLevel : int) : void {
            _levelController.autoLevelCapping = newLevel;
        }

        /** Return a Vector of quality level **/
        public function get levels() : Vector.<Level> {
            return _levelLoader.levels;
        };

        /** Return the current playback position. **/
        public function get position() : Number {
            return _streamBuffer.position;
        };

        /** Return the live main playlist sliding in seconds since previous out of buffer seek(). **/
        public function get liveSlidingMain() : Number {
            return _streamBuffer.liveSlidingMain;
        }

        /** Return the live altaudio playlist sliding in seconds since previous out of buffer seek(). **/
        public function get liveSlidingAltAudio() : Number {
            return _streamBuffer.liveSlidingAltAudio;
        }

        /** Return the current playback state. **/
        public function get playbackState() : String {
            return _hlsNetStream.playbackState;
        };

        /** Return the current seek state. **/
        public function get seekState() : String {
            return _hlsNetStream.seekState;
        };

        /** Return the current watched time **/
        public function get watched() : Number {
            return _hlsNetStream.watched;
        };

        /** Return the total nb of dropped video frames since last call to hls.load() **/
        public function get droppedFrames() : Number {
            return _hlsNetStream.droppedFrames;
        };

        /** Return the type of stream (VOD/LIVE). **/
        public function get type() : String {
            return _levelLoader.type;
        };

        /** Load and parse a new HLS URL **/
        public function load(url : String) : void {
            _level = 0;
            _hlsNetStream.close();
            _levelLoader.load(url);
        };

        /** return HLS NetStream **/
        public function get stream() : NetStream {
            return _hlsNetStream;
        }

        public function get client() : Object {
            return _client;
        }

        public function set client(value : Object) : void {
            _client = value;
        }

        /** get audio tracks list**/
        public function get audioTracks() : Vector.<AudioTrack> {
            return _audioTrackController.audioTracks;
        };

        /** get alternate audio tracks list from playlist **/
        public function get altAudioTracks() : Vector.<AltAudioTrack> {
            return _levelLoader.altAudioTracks;
        };

        /** get index of the selected audio track (index in audio track lists) **/
        public function get audioTrack() : int {
            return _audioTrackController.audioTrack;
        };

        /** select an audio track, based on its index in audio track lists**/
        public function set audioTrack(val : int) : void {
            _audioTrackController.audioTrack = val;
        }

        /* set stage */
        public function set stage(stage : Stage) : void {
            _stage = stage;
            this.dispatchEvent(new HLSEvent(HLSEvent.STAGE_SET));
        }

        /* get stage */
        public function get stage() : Stage {
            return _stage;
        }

        /* set URL stream loader */
        public function set URLstream(urlstream : Class) : void {
            _hlsURLStream = urlstream;
        }

        /* retrieve URL stream loader */
        public function get URLstream() : Class {
            return _hlsURLStream;
        }

        /* set URL stream loader */
        public function set URLloader(urlloader : Class) : void {
            _hlsURLLoader = urlloader;
        }

        /* retrieve URL stream loader */
        public function get URLloader() : Class {
            return _hlsURLLoader;
        }
        /* start/restart playlist/fragment loading.
           this is only effective if MANIFEST_PARSED event has been triggered already */
        public function startLoad() : void {
            if(levels && levels.length) {
                this.dispatchEvent(new HLSEvent(HLSEvent.LEVEL_SWITCH, startLevel));
            }
        }
    }
}

fix typo

fix typo


// vim: tabstop=4 shiftwidth=4

// Copyright (c) 2010 , NetEase.com,Inc. All rights reserved.
// Copyright (c) 2012 , Yang Bo. All rights reserved.
//
// Author: Yang Bo (pop.atry@gmail.com)
//
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.

package com.netease.protobuf {
	import flash.errors.*
	import flash.utils.*
	/**
	 * @private
	 */
	public final class ReadUtils {
		public static function skip(input:IDataInput, wireType:uint):void {
			switch (wireType) {
			case WireType.VARINT:
				while (input.readUnsignedByte() > 0x80) {}
				break
			case WireType.FIXED_64_BIT:
				input.readInt()
				input.readInt()
				break
			case WireType.LENGTH_DELIMITED:
				for (var i:uint = read$TYPE_UINT32(input); i != 0; i--) {
					input.readByte()
				}
				break
			case WireType.FIXED_32_BIT:
				input.readInt()
				break
			default:
				throw new IOError("Invalid wire type: " + wireType)
			}
		}
		public static function read$TYPE_DOUBLE(input:IDataInput):Number {
			return input.readDouble()
		}
		public static function read$TYPE_FLOAT(input:IDataInput):Number {
			return input.readFloat()
		}
		public static function read$TYPE_INT64(input:IDataInput):Int64 {
			const result:Int64 = new Int64
			var b:uint
			var i:uint = 0
			for (;; i += 7) {
				b = input.readUnsignedByte()
				if (i == 28) {
					break
				} else {
					if (b >= 0x80) {
						result.low |= ((b & 0x7f) << i)
					} else {
						result.low |= (b << i)
						return result
					}
				}
			}
			if (b >= 0x80) {
				b &= 0x7f
				result.low |= (b << i)
				result.high = b >>> 4
			} else {
				result.low |= (b << i)
				result.high = b >>> 4
				return result
			}
			for (i = 3;; i += 7) {
				b = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result.high |= ((b & 0x7f) << i)
					} else {
						result.high |= (b << i)
						break
					}
				}
			}
			return result
		}
		public static function read$TYPE_UINT64(input:IDataInput):UInt64 {
			const result:UInt64 = new UInt64
			var b:uint
			var i:uint = 0
			for (;; i += 7) {
				b = input.readUnsignedByte()
				if (i == 28) {
					break
				} else {
					if (b >= 0x80) {
						result.low |= ((b & 0x7f) << i)
					} else {
						result.low |= (b << i)
						return result
					}
				}
			}
			if (b >= 0x80) {
				b &= 0x7f
				result.low |= (b << i)
				result.high = b >>> 4
			} else {
				result.low |= (b << i)
				result.high = b >>> 4
				return result
			}
			for (i = 3;; i += 7) {
				b = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result.high |= ((b & 0x7f) << i)
					} else {
						result.high |= (b << i)
						break
					}
				}
			}
			return result
		}
		public static function read$TYPE_INT32(input:IDataInput):int {
			return int(read$TYPE_UINT32(input))
		}
		public static function read$TYPE_FIXED64(input:IDataInput):UInt64 {
			const result:UInt64 = new UInt64
			result.low = input.readUnsignedInt()
			result.high = input.readUnsignedInt()
			return result
		}
		public static function read$TYPE_FIXED32(input:IDataInput):uint {
			return input.readUnsignedInt()
		}
		public static function read$TYPE_BOOL(input:IDataInput):Boolean {
			return read$TYPE_UINT32(input) != 0
		}
		public static function read$TYPE_STRING(input:IDataInput):String {
			const length:uint = read$TYPE_UINT32(input)
			return input.readUTFBytes(length)
		}
		public static function read$TYPE_BYTES(input:IDataInput):ByteArray {
			const result:ByteArray = new ByteArray
			const length:uint = read$TYPE_UINT32(input)
			if (length > 0) {
				input.readBytes(result, 0, length)
			}
			return result
		}
		public static function read$TYPE_UINT32(input:IDataInput):uint {
			var result:uint = 0
			for (var i:uint = 0;; i += 7) {
				const b:uint = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result |= ((b & 0x7f) << i)
					} else {
						result |= (b << i)
						break
					}
				} else {
					while (input.readUnsignedByte() >= 0x80) {}
					break
				}
			}
			return result
		}
		public static function read$TYPE_ENUM(input:IDataInput):int {
			return read$TYPE_INT32(input)
		}
		public static function read$TYPE_SFIXED32(input:IDataInput):int {
			return input.readInt()
		}
		public static function read$TYPE_SFIXED64(input:IDataInput):Int64 {
			const result:Int64 = new Int64
			result.low = input.readUnsignedInt()
			result.high = input.readInt()
			return result
		}
		public static function read$TYPE_SINT32(input:IDataInput):int {
			return ZigZag.decode32(read$TYPE_UINT32(input))
		}
		public static function read$TYPE_SINT64(input:IDataInput):Int64 {
			const result:Int64 = read$TYPE_INT64(input)
			const low:uint = result.low
			const high:uint = result.high
			result.low = ZigZag.decode64low(low, high)
			result.high = ZigZag.decode64high(low, high)
			return result
		}
		public static function read$TYPE_MESSAGE(input:IDataInput,
				message:Message):Message {
			const length:uint = read$TYPE_UINT32(input)
			if (input.bytesAvailable < length) {
				throw new IOError("Invalid message length: " + length)
			}
			const bytesAfterSlice:uint = input.bytesAvailable - length
			message.used_by_generated_code::readFromSlice(input, bytesAfterSlice)
			if (input.bytesAvailable != bytesAfterSlice) {
				throw new IOError("Invalid nested message")
			}
			return message
		}
		public static function readPackedRepeated(input:IDataInput,
				readFuntion:Function, value:Array):void {
			const length:uint = read$TYPE_UINT32(input)
			if (input.bytesAvailable < length) {
				throw new IOError("Invalid message length: " + length)
			}
			const bytesAfterSlice:uint = input.bytesAvailable - length
			while (input.bytesAvailable > bytesAfterSlice) {
				value.push(readFuntion(input))
			}
			if (input.bytesAvailable != bytesAfterSlice) {
				throw new IOError("Invalid packed repeated data")
			}
		}
	}
}

// vim: tabstop=4 shiftwidth=4

// Copyright (c) 2010 , NetEase.com,Inc. All rights reserved.
// Copyright (c) 2012 , Yang Bo. All rights reserved.
//
// Author: Yang Bo (pop.atry@gmail.com)
//
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.

package com.netease.protobuf {
	import flash.errors.*
	import flash.utils.*
	/**
	 * @private
	 */
	public final class ReadUtils {
		public static function skip(input:IDataInput, wireType:uint):void {
			switch (wireType) {
			case WireType.VARINT:
				while (input.readUnsignedByte() >= 0x80) {}
				break
			case WireType.FIXED_64_BIT:
				input.readInt()
				input.readInt()
				break
			case WireType.LENGTH_DELIMITED:
				for (var i:uint = read$TYPE_UINT32(input); i != 0; i--) {
					input.readByte()
				}
				break
			case WireType.FIXED_32_BIT:
				input.readInt()
				break
			default:
				throw new IOError("Invalid wire type: " + wireType)
			}
		}
		public static function read$TYPE_DOUBLE(input:IDataInput):Number {
			return input.readDouble()
		}
		public static function read$TYPE_FLOAT(input:IDataInput):Number {
			return input.readFloat()
		}
		public static function read$TYPE_INT64(input:IDataInput):Int64 {
			const result:Int64 = new Int64
			var b:uint
			var i:uint = 0
			for (;; i += 7) {
				b = input.readUnsignedByte()
				if (i == 28) {
					break
				} else {
					if (b >= 0x80) {
						result.low |= ((b & 0x7f) << i)
					} else {
						result.low |= (b << i)
						return result
					}
				}
			}
			if (b >= 0x80) {
				b &= 0x7f
				result.low |= (b << i)
				result.high = b >>> 4
			} else {
				result.low |= (b << i)
				result.high = b >>> 4
				return result
			}
			for (i = 3;; i += 7) {
				b = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result.high |= ((b & 0x7f) << i)
					} else {
						result.high |= (b << i)
						break
					}
				}
			}
			return result
		}
		public static function read$TYPE_UINT64(input:IDataInput):UInt64 {
			const result:UInt64 = new UInt64
			var b:uint
			var i:uint = 0
			for (;; i += 7) {
				b = input.readUnsignedByte()
				if (i == 28) {
					break
				} else {
					if (b >= 0x80) {
						result.low |= ((b & 0x7f) << i)
					} else {
						result.low |= (b << i)
						return result
					}
				}
			}
			if (b >= 0x80) {
				b &= 0x7f
				result.low |= (b << i)
				result.high = b >>> 4
			} else {
				result.low |= (b << i)
				result.high = b >>> 4
				return result
			}
			for (i = 3;; i += 7) {
				b = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result.high |= ((b & 0x7f) << i)
					} else {
						result.high |= (b << i)
						break
					}
				}
			}
			return result
		}
		public static function read$TYPE_INT32(input:IDataInput):int {
			return int(read$TYPE_UINT32(input))
		}
		public static function read$TYPE_FIXED64(input:IDataInput):UInt64 {
			const result:UInt64 = new UInt64
			result.low = input.readUnsignedInt()
			result.high = input.readUnsignedInt()
			return result
		}
		public static function read$TYPE_FIXED32(input:IDataInput):uint {
			return input.readUnsignedInt()
		}
		public static function read$TYPE_BOOL(input:IDataInput):Boolean {
			return read$TYPE_UINT32(input) != 0
		}
		public static function read$TYPE_STRING(input:IDataInput):String {
			const length:uint = read$TYPE_UINT32(input)
			return input.readUTFBytes(length)
		}
		public static function read$TYPE_BYTES(input:IDataInput):ByteArray {
			const result:ByteArray = new ByteArray
			const length:uint = read$TYPE_UINT32(input)
			if (length > 0) {
				input.readBytes(result, 0, length)
			}
			return result
		}
		public static function read$TYPE_UINT32(input:IDataInput):uint {
			var result:uint = 0
			for (var i:uint = 0;; i += 7) {
				const b:uint = input.readUnsignedByte()
				if (i < 32) {
					if (b >= 0x80) {
						result |= ((b & 0x7f) << i)
					} else {
						result |= (b << i)
						break
					}
				} else {
					while (input.readUnsignedByte() >= 0x80) {}
					break
				}
			}
			return result
		}
		public static function read$TYPE_ENUM(input:IDataInput):int {
			return read$TYPE_INT32(input)
		}
		public static function read$TYPE_SFIXED32(input:IDataInput):int {
			return input.readInt()
		}
		public static function read$TYPE_SFIXED64(input:IDataInput):Int64 {
			const result:Int64 = new Int64
			result.low = input.readUnsignedInt()
			result.high = input.readInt()
			return result
		}
		public static function read$TYPE_SINT32(input:IDataInput):int {
			return ZigZag.decode32(read$TYPE_UINT32(input))
		}
		public static function read$TYPE_SINT64(input:IDataInput):Int64 {
			const result:Int64 = read$TYPE_INT64(input)
			const low:uint = result.low
			const high:uint = result.high
			result.low = ZigZag.decode64low(low, high)
			result.high = ZigZag.decode64high(low, high)
			return result
		}
		public static function read$TYPE_MESSAGE(input:IDataInput,
				message:Message):Message {
			const length:uint = read$TYPE_UINT32(input)
			if (input.bytesAvailable < length) {
				throw new IOError("Invalid message length: " + length)
			}
			const bytesAfterSlice:uint = input.bytesAvailable - length
			message.used_by_generated_code::readFromSlice(input, bytesAfterSlice)
			if (input.bytesAvailable != bytesAfterSlice) {
				throw new IOError("Invalid nested message")
			}
			return message
		}
		public static function readPackedRepeated(input:IDataInput,
				readFuntion:Function, value:Array):void {
			const length:uint = read$TYPE_UINT32(input)
			if (input.bytesAvailable < length) {
				throw new IOError("Invalid message length: " + length)
			}
			const bytesAfterSlice:uint = input.bytesAvailable - length
			while (input.bytesAvailable > bytesAfterSlice) {
				value.push(readFuntion(input))
			}
			if (input.bytesAvailable != bytesAfterSlice) {
				throw new IOError("Invalid packed repeated data")
			}
		}
	}
}

Fix #35

Fix #35


package ageofai.unit.base
{
    import ageofai.map.constant.CMap;
    import ageofai.unit.view.LifeBarView;
    import ageofai.unit.vo.UnitVO;

    import caurina.transitions.Tweener;

    import common.mvc.view.base.ABaseView;
    import common.utils.MathUtil;

    import flash.display.DisplayObject;
    import flash.geom.Point;

    /**
     * ...
     * @author Tibor Túri
     */
    public class BaseUnitView extends ABaseView implements IUnitView
    {

        public var speed:Number;

        private var _graphicUI:DisplayObject;
        public var lifebar:LifeBarView;
        public var unitVO:UnitVO;

        public function BaseUnitView()
        {

        }

        protected function createUI( uiClass:Class ):void
        {
            this._graphicUI = new uiClass;
            this.addChild( this._graphicUI );

            this._graphicUI.x = CMap.TILE_SIZE / 2;
            this._graphicUI.y = CMap.TILE_SIZE / 2;
        }

        public function createLifeBar():void
        {
            this.lifebar = new LifeBarView();
            this.addChild( this.lifebar );

            this.lifebar.x = ( CMap.TILE_SIZE - this.lifebar.barWidth ) / 2;
            this.lifebar.y = -30;
            this.lifebar.drawProcessBar( 1 );
        }

        public function moveTo( villagerVO:UnitVO ):void
        {
            if ( this == villagerVO.view )
            {
                var movingTime:Number = this.calculateMovingTime( new Point( villagerVO.position.x, villagerVO.position.y ) );
                Tweener.addTween( this, {
                    x: villagerVO.position.x,
                    y: villagerVO.position.y,
                    time: movingTime,
                    transition: "linear"
                } )
                this.calculateDirection( new Point( villagerVO.position.x, villagerVO.position.y ) );
            }
        }

        private function calculateDirection( targetPoint:Point ):void
        {
            var direction:Number = targetPoint.x > this.x ? 1 : -1;
            this.scaleX = direction;
        }

        public function calculateMovingTime( point:Point ):Number
        {
            var distance:Number;
            var movingTime:Number;
            var currentPosition:Point = this.getCurrentPosition();

            distance = MathUtil.distance( currentPosition.x, currentPosition.y, point.x, point.y );

            movingTime = Math.abs( distance ) / CMap.TILE_SIZE * this.speed;

            return movingTime;
        }

        private function getCurrentPosition():Point
        {
            return new Point( this.x, this.y );
        }

        public function get graphicUI():DisplayObject
        {
            return _graphicUI;
        }
    }

}

package ageofai.unit.base
{
    import ageofai.map.constant.CMap;
    import ageofai.unit.view.LifeBarView;
    import ageofai.unit.vo.UnitVO;

    import caurina.transitions.Tweener;

    import common.mvc.view.base.ABaseView;
    import common.utils.MathUtil;

    import flash.display.DisplayObject;
    import flash.geom.Point;

    /**
     * ...
     * @author Tibor Túri
     */
    public class BaseUnitView extends ABaseView implements IUnitView
    {

        public var speed:Number;

        private var _graphicUI:DisplayObject;
        public var lifebar:LifeBarView;
        public var unitVO:UnitVO;

        public function BaseUnitView()
        {

        }

        protected function createUI( uiClass:Class ):void
        {
            this._graphicUI = new uiClass;
            this.addChild( this._graphicUI );

            this._graphicUI.x = CMap.TILE_SIZE / 2;
            this._graphicUI.y = CMap.TILE_SIZE / 2;
        }

        public function createLifeBar():void
        {
            this.lifebar = new LifeBarView();
            this.addChild( this.lifebar );

            this.lifebar.x = ( CMap.TILE_SIZE - this.lifebar.barWidth ) / 2;
            this.lifebar.y = -30;
            this.lifebar.drawProcessBar( 1 );
        }

        public function moveTo( villagerVO:UnitVO ):void
        {
            if ( this == villagerVO.view )
            {
                var movingTime:Number = this.calculateMovingTime( new Point( villagerVO.position.x, villagerVO.position.y ) );
                Tweener.addTween( this, {
                    x: villagerVO.position.x,
                    y: villagerVO.position.y,
                    time: movingTime,
                    transition: "linear"
                } )
                this.calculateDirection( new Point( villagerVO.position.x, villagerVO.position.y ) );
            }
        }

        private function calculateDirection( targetPoint:Point ):void
        {
            var direction:Number = targetPoint.x > this.x ? 1 : -1;
            this._graphicUI.scaleX = direction;
        }

        public function calculateMovingTime( point:Point ):Number
        {
            var distance:Number;
            var movingTime:Number;
            var currentPosition:Point = this.getCurrentPosition();

            distance = MathUtil.distance( currentPosition.x, currentPosition.y, point.x, point.y );

            movingTime = Math.abs( distance ) / CMap.TILE_SIZE * this.speed;

            return movingTime;
        }

        private function getCurrentPosition():Point
        {
            return new Point( this.x, this.y );
        }

        public function get graphicUI():DisplayObject
        {
            return _graphicUI;
        }
    }

}

scale fix

scale fix

scale fix
ó


package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.render.Effect;
	import aerys.minko.render.geometry.Geometry;
	import aerys.minko.render.material.Material;
	import aerys.minko.render.material.basic.BasicMaterial;
	import aerys.minko.render.material.basic.BasicShader;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.mesh.MeshVisibilityController;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.binding.DataProvider;
	import aerys.minko.type.enum.DataProviderUsage;
	import aerys.minko.type.math.Ray;

	use namespace minko_scene;

	/**
	 * Mesh objects are a visible instance of a Geometry rendered using a specific
	 * Effect with specific rendering properties.
	 *
	 *

	 * Those rendering properties are stored in a DataBindings object so they can
	 * be directly used by the shaders in the rendering API.
	 *

	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public class Mesh extends AbstractSceneNode
	{
		public static const DEFAULT_MATERIAL	: Material	= new BasicMaterial();

		private var _geometry			: Geometry					= null;
		private var _properties			: DataProvider				= null;
		private var _material			: Material					= null;
		private var _bindings			: DataBindings				= null;

		private var _visibility			: MeshVisibilityController	= new MeshVisibilityController();

		private var _frame				: uint						= 0;

		private var _cloned				: Signal 					= new Signal('Mesh.clones');
		private var _materialChanged	: Signal					= new Signal('Mesh.materialChanged');
		private var _frameChanged		: Signal					= new Signal('Mesh.frameChanged');
		private var _geometryChanged	: Signal					= new Signal('Mesh.geometryChanged');

		/**
		 * A DataProvider object already bound to the Mesh bindings.
		 *
		 *

		 * // set the "diffuseColor" property to 0x0000ffff
		 * mesh.properties.diffuseColor = 0x0000ffff;
		 *
		 * // animate the "diffuseColor" property
		 * mesh.addController(
		 *   new AnimationController(
		 * 	  new <ITimeline>[new ColorTimeline(
		 * 	    "dataProvider.diffuseColor",
		 * 	    5000,
		 * 	    new <uint>[0xffffffff, 0xffffff00, 0xffffffff]
		 *    )]
		 *   )
		 * );
		 *

		 *
		 * @return
		 *
		 */
		public function get properties() : DataProvider
		{
			return _properties;
		}

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

				_properties = value;

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

		public function get material() : Material
		{
			return _material;
		}
		public function set material(value : Material) : void
		{
			if (_material != value)
			{
				if (_material)
					_bindings.removeProvider(_material);

				_material = value;

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

		/**
		 * The rendering properties provided to the shaders to customize
		 * how the mesh will appear on screen.
		 *
		 * @return
		 *
		 */
		public function get bindings() : DataBindings
		{
			return _bindings;
		}

		/**
		 * The Geometry of the mesh.
		 * @return
		 *
		 */
		public function get geometry() : Geometry
		{
			return _geometry;
		}

		public function set geometry(value : Geometry) : void
		{
			if (_geometry != value)
			{
				var oldGeometry	: Geometry = _geometry;

				_geometry = value;
				_geometryChanged.execute(this, oldGeometry, value);
			}
		}

		/**
		 * Whether the mesh is visible or not.
		 *
		 * @return
		 *
		 */
		public function get visible() : Boolean
		{
			return _visibility.visible;
		}
		public function set visible(value : Boolean) : void
		{
			_visibility.visible = value;
		}

		public function get frustumCulling() : uint
		{
			return _visibility.frustumCulling;
		}
		public function set frustumCulling(value : uint) : void
		{
			_visibility.frustumCulling = value;
		}

		public function get cloned() : Signal
		{
			return _cloned;
		}

		public function get materialChanged() : Signal
		{
			return _materialChanged;
		}

		public function get frameChanged() : Signal
		{
			return _frameChanged;
		}

		public function get geometryChanged() : Signal
		{
			return _geometryChanged;
		}

		public function get frame() : uint
		{
			return _frame;
		}
		public function set frame(value : uint) : void
		{
			if (_frame != value)
			{
				var oldFrame : uint = _frame;

				_frame = value;
				_frameChanged.execute(this, oldFrame, value);
			}
		}

		public function Mesh(geometry	: Geometry	= null,
							 material	: Material	= null,
							 ...controllers)
		{
			super();

			initialize(geometry, material, controllers);
		}

		private function initialize(geometry	: Geometry,
									material	: Material,
									controllers	: Array) : void
		{
			_bindings = new DataBindings(this);
			this.properties = new DataProvider(properties, 'meshProperties', DataProviderUsage.EXCLUSIVE);

			_geometry = geometry;
			this.material = material || DEFAULT_MATERIAL;

//			_visibility.frustumCulling = FrustumCulling.BOX ^ FrustumCulling.TOP_BOX;
			addController(_visibility);

			while (controllers && !(controllers[0] is AbstractController))
				controllers = controllers[0];

			if (controllers)
				for each (var ctrl : AbstractController in controllers)
					addController(ctrl);
		}

		public function cast(ray : Ray, maxDistance : Number = Number.POSITIVE_INFINITY) : Number
		{
			return _geometry.boundingBox.testRay(
				ray,
				worldToLocal,
				maxDistance
			);
		}

		override minko_scene function cloneNode() : AbstractSceneNode
		{
			var clone : Mesh = new Mesh();

			clone.name 		= name;
			clone.geometry 	= _geometry;

			clone.properties = DataProvider(_properties.clone());
			clone._bindings.copySharedProvidersFrom(_bindings);

			clone.transform.copyFrom(transform);
			clone.material = _material;

			this.cloned.execute(this, clone);

			return clone;
		}

		override protected function addedToSceneHandler(child : ISceneNode, scene : Scene) : void
		{
			super.addedToSceneHandler(child, scene);

			if (child === this)
				_bindings.addProvider(transformData);
		}

		override protected function removedFromSceneHandler(child : ISceneNode, scene : Scene) : void
		{
			super.removedFromSceneHandler(child, scene);

			if (child === this)
				_bindings.removeProvider(transformData);
		}
	}
}

package aerys.minko.scene.node
{
	import aerys.minko.ns.minko_scene;
	import aerys.minko.render.geometry.Geometry;
	import aerys.minko.render.material.Material;
	import aerys.minko.render.material.basic.BasicMaterial;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.mesh.MeshVisibilityController;
	import aerys.minko.scene.controller.mesh.VisibilityController;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.binding.DataProvider;
	import aerys.minko.type.enum.DataProviderUsage;
	import aerys.minko.type.math.Ray;

	use namespace minko_scene;

	/**
	 * Mesh objects are a visible instance of a Geometry rendered using a specific
	 * Effect with specific rendering properties.
	 *
	 *

	 * Those rendering properties are stored in a DataBindings object so they can
	 * be directly used by the shaders in the rendering API.
	 *

	 *
	 * @author Jean-Marc Le Roux
	 *
	 */
	public class Mesh extends AbstractSceneNode
	{
		public static const DEFAULT_MATERIAL	: Material	= new BasicMaterial();

		private var _geometry			: Geometry;
		private var _properties			: DataProvider;
		private var _material			: Material;
		private var _bindings			: DataBindings;

		private var _visibility			: VisibilityController;

		private var _frame				: uint;

		private var _cloned				: Signal;
		private var _materialChanged	: Signal;
		private var _frameChanged		: Signal;
		private var _geometryChanged	: Signal;

		/**
		 * A DataProvider object already bound to the Mesh bindings.
		 *
		 *

		 * // set the "diffuseColor" property to 0x0000ffff
		 * mesh.properties.diffuseColor = 0x0000ffff;
		 *
		 * // animate the "diffuseColor" property
		 * mesh.addController(
		 *   new AnimationController(
		 * 	  new <ITimeline>[new ColorTimeline(
		 * 	    "dataProvider.diffuseColor",
		 * 	    5000,
		 * 	    new <uint>[0xffffffff, 0xffffff00, 0xffffffff]
		 *    )]
		 *   )
		 * );
		 *

		 *
		 * @return
		 *
		 */
		public function get properties() : DataProvider
		{
			return _properties;
		}

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

				_properties = value;

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

		public function get material() : Material
		{
			return _material;
		}
		public function set material(value : Material) : void
		{
			if (_material != value)
			{
				if (_material)
					_bindings.removeProvider(_material);

				_material = value;

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

		/**
		 * The rendering properties provided to the shaders to customize
		 * how the mesh will appear on screen.
		 *
		 * @return
		 *
		 */
		public function get bindings() : DataBindings
		{
			return _bindings;
		}

		/**
		 * The Geometry of the mesh.
		 * @return
		 *
		 */
		public function get geometry() : Geometry
		{
			return _geometry;
		}

		public function set geometry(value : Geometry) : void
		{
			if (_geometry != value)
			{
				var oldGeometry	: Geometry = _geometry;

				_geometry = value;
				_geometryChanged.execute(this, oldGeometry, value);
			}
		}

		/**
		 * Whether the mesh is visible or not.
		 *
		 * @return
		 *
		 */
		public function get visible() : Boolean
		{
			return _visibility.visible;
		}
		public function set visible(value : Boolean) : void
		{
			_visibility.visible = value;
		}

		public function get frustumCulling() : uint
		{
			return _visibility.frustumCulling;
		}
		public function set frustumCulling(value : uint) : void
		{
			_visibility.frustumCulling = value;
		}

		public function get cloned() : Signal
		{
			return _cloned;
		}

		public function get materialChanged() : Signal
		{
			return _materialChanged;
		}

		public function get frameChanged() : Signal
		{
			return _frameChanged;
		}

		public function get geometryChanged() : Signal
		{
			return _geometryChanged;
		}

		public function get frame() : uint
		{
			return _frame;
		}
		public function set frame(value : uint) : void
		{
			if (_frame != value)
			{
				var oldFrame : uint = _frame;

				_frame = value;
				_frameChanged.execute(this, oldFrame, value);
			}
		}

		public function Mesh(geometry	: Geometry	= null,
							 material	: Material	= null,
							 name		: String	= null)
		{
			super();

			initialize(geometry, material, name);
		}

		private function initialize(geometry	: Geometry,
									material	: Material,
									name		: String) : void
		{
			if (name)
				this.name = name;

			_cloned = new Signal('Mesh.clones');
			_materialChanged = new Signal('Mesh.materialChanged');
			_frameChanged = new Signal('Mesh.frameChanged');
			_geometryChanged = new Signal('Mesh.geometryChanged');

			_bindings = new DataBindings(this);
			this.properties = new DataProvider(properties, 'meshProperties', DataProviderUsage.EXCLUSIVE);

			_geometry = geometry;
			this.material = material || DEFAULT_MATERIAL;

			_visibility = new VisibilityController();
//			_visibility.frustumCulling = FrustumCulling.BOX ^ FrustumCulling.TOP_BOX;
			addController(_visibility);
		}

		public function cast(ray : Ray, maxDistance : Number = Number.POSITIVE_INFINITY) : Number
		{
			return _geometry.boundingBox.testRay(
				ray,
				worldToLocal,
				maxDistance
			);
		}

		override minko_scene function cloneNode() : AbstractSceneNode
		{
			var clone : Mesh = new Mesh();

			clone.name 		= name;
			clone.geometry 	= _geometry;

			clone.properties = DataProvider(_properties.clone());
			clone._bindings.copySharedProvidersFrom(_bindings);

			clone.transform.copyFrom(transform);
			clone.material = _material;

			this.cloned.execute(this, clone);

			return clone;
		}

		override protected function addedToSceneHandler(child : ISceneNode, scene : Scene) : void
		{
			super.addedToSceneHandler(child, scene);

			if (child === this)
				_bindings.addProvider(transformData);
		}

		override protected function removedFromSceneHandler(child : ISceneNode, scene : Scene) : void
		{
			super.removedFromSceneHandler(child, scene);

			if (child === this)
				_bindings.removeProvider(transformData);
		}
	}
}

remove controllers from Mesh variadic constructor and replace them with a name : String optional argument


/*
* actionscript-cafe SignalAggregator 18 avr. 2011 adesmarais
*
* Created by Servebox
* Copyright 2010 Servebox (c) All rights reserved. You may not use, distribute
* or modify this code under its source or binary form
* without the express authorization of ServeBox. Contact : info@servebox.com
*/
package org.servebox.cafe.core.signal
{
	import org.servebox.cafe.core.observer.AbstractObservable;
	import org.servebox.cafe.core.observer.IObservable;
	import org.servebox.cafe.core.observer.IObserver;
	import org.servebox.cafe.core.observer.Notification;

	public class SignalAggregator extends AbstractObservable
	{

		public function SignalAggregator()
		{
		}

		override public function registerObserver(o:IObserver, notificationFilters:Array=null):void
		{
			if ( !(o is ISignalObserver ) )
			{
				throw new Error("Observer of SignalAggregator should be ISignalObserver");
			}
			super.registerObserver( ISignalObserver( o ), notificationFilters );
		}

		override public function unregisterObserver(o:IObserver):void
		{
			if ( !(o is ISignalObserver ) )
			{
				throw new Error("Observer of SignalAggregator should be ISignalObserver");
			}
			super.unregisterObserver( ISignalObserver( o ) );
		}

		public function signal( type : String, ... cargo) : void
		{

			if( cargo.length > 0 )
			{
				var signal : Signal = new Signal(type);
				signal.setCargoList(cargo);
				super.signalObservers( signal );
			}
			else
			{
				super.signalObservers( new Signal(type) );
			}
		}

		override protected function handleFilters(o : IObserver, notificationFilters : Array = null) : void
		{
			// Label label_filters
			for each( var notificationFilter : String in notificationFilters )
			{
				addObserver(o,notificationFilter);
			}
		}

	}
}

/*
* actionscript-cafe SignalAggregator 18 avr. 2011 adesmarais
*
* Created by Servebox
* Copyright 2010 Servebox (c) All rights reserved. You may not use, distribute
* or modify this code under its source or binary form
* without the express authorization of ServeBox. Contact : info@servebox.com
*/
package org.servebox.cafe.core.signal
{
	import mx.logging.ILogger;
	import mx.logging.Log;

	import org.servebox.cafe.core.observer.AbstractObservable;
	import org.servebox.cafe.core.observer.IObservable;
	import org.servebox.cafe.core.observer.IObserver;
	import org.servebox.cafe.core.observer.Notification;

	public class SignalAggregator extends AbstractObservable
	{

		public var log : ILogger = Log.getLogger("SignalAggregator");

		override public function registerObserver(o:IObserver, notificationFilters:Array=null):void
		{
			if ( !(o is ISignalObserver ) )
			{
				throw new Error("Observer of SignalAggregator should be ISignalObserver");
			}
			super.registerObserver( ISignalObserver( o ), notificationFilters );
		}

		override public function unregisterObserver(o:IObserver):void
		{
			if ( !(o is ISignalObserver ) )
			{
				throw new Error("Observer of SignalAggregator should be ISignalObserver");
			}
			super.unregisterObserver( ISignalObserver( o ) );
		}

		public function signal( type : String, ... cargo) : void
		{
			log.info("SignalAggregator runs " + type );

			if( cargo.length > 0 )
			{
				var signal : Signal = new Signal(type);
				signal.setCargoList(cargo);
				super.signalObservers( signal );
			}
			else
			{
				super.signalObservers( new Signal(type) );
			}
		}

		override protected function handleFilters(o : IObserver, notificationFilters : Array = null) : void
		{
			// Label label_filters
			for each( var notificationFilter : String in notificationFilters )
			{
				addObserver(o,notificationFilter);
			}
		}

	}
}

add lOgger.

add lOgger.