package aerys.minko.render.geometry.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IVertexStream;
	import aerys.minko.render.geometry.stream.IndexStream;
	import aerys.minko.type.Factory;
	import aerys.minko.type.math.Plane;
	import aerys.minko.type.math.Vector4;

	public final class TriangleReference
	{
		use namespace minko_stream;

		private static const DUMMY_INDICES			: Vector.<uint>	= new <uint>[0, 1, 2];

		minko_stream static const UPDATE_NONE		: uint		= 0;
		minko_stream static const UPDATE_NORMAL		: uint		= 1;
		minko_stream static const UPDATE_PLANE		: uint		= 2;
		minko_stream static const UPDATE_CENTER		: uint		= 4;
		minko_stream static const UPDATE_ALL		: uint		= 1 | 2 | 4;

		minko_stream var _index		: uint				= 0;
		minko_stream var _update	: uint				= UPDATE_ALL;

		private var _indexStream	: IndexStream		= null;

		private var _v0				: VertexReference	= null;
		private var _v1				: VertexReference	= null;
		private var _v2				: VertexReference	= null;

		private var _i0				: uint				= 0;
		private var _i1				: uint				= 0;
		private var _i2				: uint				= 0;

		public function get index()	: int
		{
			return _index;
		}

		public function get v0() : VertexReference
		{
			return _v0;
		}
		public function get v1() : VertexReference
		{
			return _v1;
		}
		public function get v2() : VertexReference
		{
			return _v2;
		}

		public function get i0() : int
		{
			return _indexStream._data[int(_index * 3)];
		}
		public function set i0(value : int) : void
		{
			_indexStream._data[int(_index * 3)] = value;
			_indexStream.invalidate();
			_v0._index = value;
			_update |= UPDATE_ALL;
		}

		public function get i1() : int
		{
			return _indexStream._data[int(_index * 3 + 1)];
		}
		public function set i1(value : int) : void
		{
			_indexStream._data[int(_index * 3 + 1)] = value;
			_indexStream.invalidate();
			_v1._index = value;
			_update |= UPDATE_ALL;
		}

		public function get i2() : int
		{
			return _indexStream._data[int(_index * 3 + 2)];
		}
		public function set i2(value : int) : void
		{
			_indexStream._data[int(_index * 3 + 2)] = value;
			_indexStream.invalidate();
			_v2._index = value;
			_update |= UPDATE_ALL;
		}

		public function TriangleReference(vertexStream 	: IVertexStream,
										  indexStream	: IndexStream,
										  index 		: uint)
		{
			_indexStream = indexStream;
			_index = index;

			initialize(vertexStream);
		}

		private function initialize(vertexStream : IVertexStream) : void
		{
			var ii : uint = _index * 3;

			// create a new triangle if it does not exist
			if (ii >= _indexStream.length)
				_indexStream.push(DUMMY_INDICES);

			_v0 = new VertexReference(vertexStream, _indexStream.get(ii));
			_v1 = new VertexReference(vertexStream, _indexStream.get(ii + 1));
			_v2 = new VertexReference(vertexStream, _indexStream.get(ii + 2));
		}

		public function invertWinding() : void
		{
			_update = UPDATE_ALL;

			var tmp : int = _i0;

			_v0._index = _i0 = _i1;
			_v1._index = tmp;

			i0 = _i1;
			i1 = tmp;
		}
	}
}

package aerys.minko.render.geometry.stream.iterator
{
	import aerys.minko.ns.minko_stream;
	import aerys.minko.render.geometry.stream.IVertexStream;
	import aerys.minko.render.geometry.stream.IndexStream;
	import aerys.minko.type.Factory;
	import aerys.minko.type.math.Plane;
	import aerys.minko.type.math.Vector4;

	public final class TriangleReference
	{
		use namespace minko_stream;

		private static const DUMMY_INDICES			: Vector.<uint>	= new <uint>[0, 1, 2];

		minko_stream static const UPDATE_NONE		: uint		= 0;
		minko_stream static const UPDATE_NORMAL		: uint		= 1;
		minko_stream static const UPDATE_PLANE		: uint		= 2;
		minko_stream static const UPDATE_CENTER		: uint		= 4;
		minko_stream static const UPDATE_ALL		: uint		= 1 | 2 | 4;

		minko_stream var _index		: uint				= 0;
		minko_stream var _update	: uint				= UPDATE_ALL;

		private var _indexStream	: IndexStream		= null;

		private var _v0				: VertexReference	= null;
		private var _v1				: VertexReference	= null;
		private var _v2				: VertexReference	= null;

		private var _i0				: uint				= 0;
		private var _i1				: uint				= 0;
		private var _i2				: uint				= 0;

		public function get index()	: int
		{
			return _index;
		}

		public function get v0() : VertexReference
		{
			return _v0;
		}
		public function get v1() : VertexReference
		{
			return _v1;
		}
		public function get v2() : VertexReference
		{
			return _v2;
		}

		public function get i0() : int
		{
			return _indexStream._data[int(_index * 3)];
		}
		public function set i0(value : int) : void
		{
			_indexStream._data[int(_index * 3)] = value;
			_indexStream.invalidate();
			_v0._index = value;
			_update |= UPDATE_ALL;
		}

		public function get i1() : int
		{
			return _indexStream._data[int(_index * 3 + 1)];
		}
		public function set i1(value : int) : void
		{
			_indexStream._data[int(_index * 3 + 1)] = value;
			_indexStream.invalidate();
			_v1._index = value;
			_update |= UPDATE_ALL;
		}

		public function get i2() : int
		{
			return _indexStream._data[int(_index * 3 + 2)];
		}
		public function set i2(value : int) : void
		{
			_indexStream._data[int(_index * 3 + 2)] = value;
			_indexStream.invalidate();
			_v2._index = value;
			_update |= UPDATE_ALL;
		}

		public function TriangleReference(vertexStream 	: IVertexStream,
										  indexStream	: IndexStream,
										  index 		: uint)
		{
			_indexStream = indexStream;
			_index = index;

			initialize(vertexStream);
		}

		private function initialize(vertexStream : IVertexStream) : void
		{
			var ii : uint = _index * 3;

			// create a new triangle if it does not exist
			if (ii >= _indexStream.length)
				_indexStream.pushVector(DUMMY_INDICES);

			_v0 = new VertexReference(vertexStream, _indexStream.get(ii));
			_v1 = new VertexReference(vertexStream, _indexStream.get(ii + 1));
			_v2 = new VertexReference(vertexStream, _indexStream.get(ii + 2));
		}

		public function invertWinding() : void
		{
			_update = UPDATE_ALL;

			var tmp : int = _i0;

			_v0._index = _i0 = _i1;
			_v1._index = tmp;

			i0 = _i1;
			i1 = tmp;
		}
	}
}

fix TriangleReference to use IndexStream.pushVector() instead of TriangleReference.push()


package ageofai.unit.utils
{
    import ageofai.home.vo.HomeVO;
    import ageofai.home.vo.MapNodeVO;
    import ageofai.map.constant.CMapNodeType;
    import ageofai.map.geom.IntPoint;
    import ageofai.map.model.IMapModel;
    import ageofai.map.model.MapNode;
    import ageofai.unit.base.IUnitView;
    import ageofai.villager.constant.CVillagerStatus;
    import ageofai.villager.model.IVillagerModel;
    import ageofai.villager.vo.VillagerVO;
    import flash.geom.Point;
	/**
     * ...
     * @author
     */
    public class VillagerAI implements IUnitAI
    {
        private var sightOffset:Array = [[ -2, -2 ], [ -2, -1 ], [ -2, 0 ], [ -2, 1 ], [ -2, 2 ],
            [ -1, -2 ], [ -1, -1 ], /*[ -1, 0 ],*/ [ -1, 1 ], [ -1, 2 ],
            [ 0, -2 ], /*[ 0, -1 ], [ 0, 1 ],*/ [ 0, 2 ],
            [ 1, -2 ], [ 1, -1 ], /*[ 1, 0 ],*/ [ 1, 1 ], [ 1, 2 ],
            [ 2, -2 ], [ 2, -1 ], [ 2, 0 ], [ 2, 1 ], [ 2, 2 ]];
        private var surroundings:Array = [[ -1, 0 ], [ 0, -1 ], [ 1, 0 ], [ 0, 1 ]];

        public function tick(villager:VillagerVO, mapModel:IMapModel, home:HomeVO):IntPoint
        {
            if ( villager.status == CVillagerStatus.IDLE )
            {
                var newPoint:IntPoint;

                var objectFounds:Vector.<MapNodeVO> = new Vector.<MapNodeVO>();

                // Check sight area
                for (var i:int = 0, count:int = sightOffset.length; i < count; i++)
                {
                    var newX:int = villager.position.x + sightOffset[i][0];
                    var newY:int = villager.position.y + sightOffset[i][1];

                    if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                    {
                        continue;
                    }

                    newPoint = new IntPoint(newX, newY);
                    var objectType:int = mapModel.map[newY][newX].objectType;
                    if (objectType != CMapNodeType.OBJECT_NULL && objectType != CMapNodeType.OBJECT_HOME)
                    {
                        var nodeVO:MapNodeVO = new MapNodeVO();
                        nodeVO.pos = newPoint;
                        nodeVO.node = mapModel.map[newY][newX];
                        objectFounds[objectFounds.length] = nodeVO;
                    }
                }

                // Check surroundings
                for (i = 0, count = surroundings.length; i < count; i++)
                {
                    newX = villager.position.x + surroundings[i][0];
                    newY = villager.position.y + surroundings[i][1];

                    if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                    {
                        continue;
                    }

                    newPoint = new IntPoint(newX, newY);

                    var objectType:int = mapModel.map[newY][newX].objectType;
                    if (objectType != CMapNodeType.OBJECT_NULL && objectType != CMapNodeType.OBJECT_HOME)
                    {
                        nodeVO = new MapNodeVO();
                        nodeVO.pos = newPoint;
                        nodeVO.node = mapModel.map[newY][newX];
                        objectFounds[objectFounds.length] = nodeVO;
                    }
                }

                home.objectFounds = home.objectFounds.concat(objectFounds);

                if ( home.objectFounds.length == 0 )
                {
                    // Move randomly
                    do {
                        var newPos:int = Math.round(Math.random() * 3);
                        newX = villager.position.x + surroundings[newPos][0];
                        newY = villager.position.y + surroundings[newPos][1];

                        if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                        {
                            continue;
                        }

                        newPoint = new IntPoint(newX, newY);
                    } while (newPoint.x < 0 || newPoint.y < 0 || newPoint.x >= mapModel.map[0].length || newPoint.y >= mapModel.map.length ||
                        !mapModel.map[newPoint.y][newPoint.x].walkable);
                }
                else
                {
                    // Go to object
                    i = 0;
                    do {
                        var path:Vector.<IntPoint> = mapModel.getPath(villager.position, home.objectFounds[i].pos);
                        i++;
                    } while (path == null && i < home.objectFounds.length)

                    if (path != null) newPoint = path[0];
                }
            }
            else
            {
                // Is current task still valid?
            }

            return newPoint;
        }
    }

}

package ageofai.unit.utils
{
    import ageofai.home.vo.HomeVO;
    import ageofai.home.vo.MapNodeVO;
    import ageofai.map.constant.CMapNodeType;
    import ageofai.map.geom.IntPoint;
    import ageofai.map.model.IMapModel;
    import ageofai.map.model.MapNode;
    import ageofai.unit.base.IUnitView;
    import ageofai.villager.constant.CVillagerStatus;
    import ageofai.villager.model.IVillagerModel;
    import ageofai.villager.vo.VillagerVO;
    import flash.geom.Point;
	/**
     * ...
     * @author
     */
    public class VillagerAI implements IUnitAI
    {
        private var sightOffset:Array = [[ -2, -2 ], [ -2, -1 ], [ -2, 0 ], [ -2, 1 ], [ -2, 2 ],
            [ -1, -2 ], [ -1, -1 ], /*[ -1, 0 ],*/ [ -1, 1 ], [ -1, 2 ],
            [ 0, -2 ], /*[ 0, -1 ], [ 0, 1 ],*/ [ 0, 2 ],
            [ 1, -2 ], [ 1, -1 ], /*[ 1, 0 ],*/ [ 1, 1 ], [ 1, 2 ],
            [ 2, -2 ], [ 2, -1 ], [ 2, 0 ], [ 2, 1 ], [ 2, 2 ]];
        private var surroundings:Array = [[ -1, 0 ], [ 0, -1 ], [ 1, 0 ], [ 0, 1 ]];

        public function tick(villager:VillagerVO, mapModel:IMapModel, home:HomeVO):IntPoint
        {
            if ( villager.status == CVillagerStatus.IDLE )
            {
                var newPoint:IntPoint;

                var objectFounds:Vector.<MapNodeVO> = new Vector.<MapNodeVO>();

                // Check sight area
                for (var i:int = 0, count:int = sightOffset.length; i < count; i++)
                {
                    var newX:int = villager.position.x + sightOffset[i][0];
                    var newY:int = villager.position.y + sightOffset[i][1];

                    if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                    {
                        continue;
                    }

                    newPoint = new IntPoint(newX, newY);
                    var objectType:int = mapModel.map[newY][newX].objectType;
                    if (objectType != CMapNodeType.OBJECT_NULL && objectType != CMapNodeType.OBJECT_HOME)
                    {
                        var nodeVO:MapNodeVO = new MapNodeVO();
                        nodeVO.pos = newPoint;
                        nodeVO.node = mapModel.map[newY][newX];
                        objectFounds[objectFounds.length] = nodeVO;
                    }
                }

                // Check surroundings
                var nextToObject:Boolean;
                for (i = 0, count = surroundings.length; i < count; i++)
                {
                    newX = villager.position.x + surroundings[i][0];
                    newY = villager.position.y + surroundings[i][1];

                    if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                    {
                        continue;
                    }

                    newPoint = new IntPoint(newX, newY);

                    var objectType:int = mapModel.map[newY][newX].objectType;
                    if (objectType != CMapNodeType.OBJECT_NULL && objectType != CMapNodeType.OBJECT_HOME)
                    {
                        nextToObject = true;
                        nodeVO = new MapNodeVO();
                        nodeVO.pos = newPoint;
                        nodeVO.node = mapModel.map[newY][newX];
                        objectFounds[objectFounds.length] = nodeVO;
                    }
                }

                home.objectFounds = home.objectFounds.concat(objectFounds);

                if ( home.objectFounds.length == 0 )
                {
                    // Move randomly
                    do {
                        var newPos:int = Math.round(Math.random() * 3);
                        newX = villager.position.x + surroundings[newPos][0];
                        newY = villager.position.y + surroundings[newPos][1];

                        if (newX < 0 || newY < 0 || newX >= mapModel.map[0].length || newY >= mapModel.map.length)
                        {
                            continue;
                        }

                        newPoint = new IntPoint(newX, newY);
                    } while (newPoint.x < 0 || newPoint.y < 0 || newPoint.x >= mapModel.map[0].length || newPoint.y >= mapModel.map.length ||
                        !mapModel.map[newPoint.y][newPoint.x].walkable);
                }
                else if (nextToObject)
                {
                    villager.status = CVillagerStatus.HARVEST;
                    newPoint = null;
                }
                else
                {
                    // Go to object
                    i = 0;
                    do {
                        var path:Vector.<IntPoint> = mapModel.getPath(villager.position, home.objectFounds[i].pos);
                        i++;
                    } while (path == null && i < home.objectFounds.length)

                    if (path != null) newPoint = path[0];
                }
            }
            else
            {
                // Is current task still valid?
            }

            return newPoint;
        }
    }

}

Change status

Change status


package aerys.minko.type.enum
{
	import aerys.minko.ns.minko_render;

	import flash.display3D.Context3DBlendFactor;

	/**
	 * The Blending class is an enumeration of the most common values possible
	 * for the Shader.blending property and the BlendingShaderPart.blend() method.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 * @see aerys.minko.type.enum.BlendingSource
	 * @see aerys.minko.type.enum.BlendingDestination
	 * @see aerys.minko.render.shader.Shader
	 * @see aerys.minko.render.shader.part.BlendingShaderPart
	 *
	 */
	public final class Blending
	{
		public static const NORMAL		: uint		= BlendingSource.ONE
													  | BlendingDestination.ZERO;

		public static const ALPHA		: uint		= BlendingSource.SOURCE_ALPHA
													  | BlendingDestination.ONE_MINUS_SOURCE_ALPHA;

		public static const ADDITIVE	: uint		= BlendingSource.SOURCE_ALPHA
													  | BlendingDestination.ONE;

		public static const LIGHT		: uint		= BlendingSource.ZERO
													  | BlendingDestination.SOURCE_COLOR;

		minko_render static const STRINGS : Vector.<String> = new <String>[
			Context3DBlendFactor.DESTINATION_ALPHA,
			Context3DBlendFactor.DESTINATION_COLOR,
			Context3DBlendFactor.ONE,
			Context3DBlendFactor.ONE_MINUS_DESTINATION_ALPHA,
			Context3DBlendFactor.ONE_MINUS_DESTINATION_COLOR,
			Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA,
			Context3DBlendFactor.SOURCE_ALPHA,
			Context3DBlendFactor.SOURCE_COLOR,
			Context3DBlendFactor.ZERO
		];
	}
}

package aerys.minko.type.enum
{
	import aerys.minko.ns.minko_render;

	import flash.display3D.Context3DBlendFactor;

	/**
	 * The Blending class is an enumeration of the most common values possible
	 * for the Shader.blending property and the BlendingShaderPart.blend() method.
	 *
	 * @author Jean-Marc Le Roux
	 *
	 * @see aerys.minko.type.enum.BlendingSource
	 * @see aerys.minko.type.enum.BlendingDestination
	 * @see aerys.minko.render.shader.Shader
	 * @see aerys.minko.render.shader.part.BlendingShaderPart
	 *
	 */
	public final class Blending
	{
		public static const OPAQUE		: uint		= BlendingSource.ONE
													  | BlendingDestination.ZERO;

		public static const ALPHA		: uint		= BlendingSource.SOURCE_ALPHA
													  | BlendingDestination.ONE_MINUS_SOURCE_ALPHA;

//		public static const ADDITIVE	: uint		= BlendingSource.SOURCE_ALPHA
//													  | BlendingDestination.ONE;

        public static const ADDITIVE	: uint		= BlendingSource.DESTINATION_ALPHA
            | BlendingDestination.ONE;

		public static const LIGHT		: uint		= BlendingSource.ZERO
													  | BlendingDestination.SOURCE_COLOR;

		minko_render static const STRINGS : Vector.<String> = new <String>[
			Context3DBlendFactor.DESTINATION_ALPHA,
			Context3DBlendFactor.DESTINATION_COLOR,
			Context3DBlendFactor.ONE,
			Context3DBlendFactor.ONE_MINUS_DESTINATION_ALPHA,
			Context3DBlendFactor.ONE_MINUS_DESTINATION_COLOR,
			Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA,
			Context3DBlendFactor.SOURCE_ALPHA,
			Context3DBlendFactor.SOURCE_COLOR,
			Context3DBlendFactor.ZERO
		];
	}
}

rename Blending.NORMAL to Blending.OPAQUE


////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed 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 com.esri.builder.controllers
{

import com.esri.ags.components.IdentityManager;
import com.esri.ags.events.IdentityManagerEvent;
import com.esri.builder.components.LogFileTarget;
import com.esri.builder.components.ToolTip;
import com.esri.builder.controllers.supportClasses.MachineDisplayName;
import com.esri.builder.controllers.supportClasses.Settings;
import com.esri.builder.controllers.supportClasses.StartupWidgetTypeLoader;
import com.esri.builder.controllers.supportClasses.WellKnownDirectories;
import com.esri.builder.eventbus.AppEvent;
import com.esri.builder.model.Model;
import com.esri.builder.model.PortalModel;
import com.esri.builder.supportClasses.LogUtil;
import com.esri.builder.views.BuilderAlert;
import com.esri.builder.views.popups.UnknownErrorPopUp;

import flash.display.DisplayObjectContainer;
import flash.events.Event;
import flash.events.UncaughtErrorEvent;
import flash.filesystem.File;
import flash.net.SharedObject;
import flash.net.URLRequestDefaults;
import flash.system.Capabilities;

import mx.core.FlexGlobals;
import mx.logging.ILogger;
import mx.logging.Log;
import mx.managers.ToolTipManager;
import mx.resources.ResourceManager;
import mx.rpc.AsyncResponder;
import mx.rpc.Responder;

import spark.components.WindowedApplication;

public final class ApplicationCompleteController
{
    private static const LOG:ILogger = LogUtil.createLogger(ApplicationCompleteController);

    private var widgetTypeLoader:StartupWidgetTypeLoader;

    private var startupSettings:Settings;

    public function ApplicationCompleteController()
    {
        AppEvent.addListener(AppEvent.APPLICATION_COMPLETE, onApplicationComplete, false, 0, true);
    }

    private function onApplicationComplete(event:AppEvent):void
    {
        applicationComplete(event.data as WindowedApplication);
        Model.instance.config.isDirty = false;
    }

    private function applicationComplete(app:WindowedApplication):void
    {
        if (Log.isInfo())
        {
            LOG.info('Starting up application.');
        }

        exportDependenciesToAppStorage();
        loadUserPreferences();
        loadWebMapSearchHistory();
        // Disable HTTP cache for HTML component
        URLRequestDefaults.cacheResponse = false;

        // Setup some XML global properties
        XML.ignoreComments = true;
        XML.ignoreWhitespace = true;
        XML.prettyIndent = 4;

        ToolTipManager.toolTipClass = ToolTip;

        // Can only have access to 'loaderInfo' when the app is complete.
        app.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);

        widgetTypeLoader = new StartupWidgetTypeLoader();
        widgetTypeLoader.addEventListener(Event.COMPLETE, widgetTypeLoader_completeHandler);
        widgetTypeLoader.loadWidgetTypes();
    }

    private function exportDependenciesToAppStorage():void
    {
        try
        {
            if (Log.isInfo())
            {
                LOG.info('Creating required folders.');
            }

            WellKnownDirectories.getInstance().customFlexViewer.createDirectory();
            WellKnownDirectories.getInstance().customModules.createDirectory();
        }
        catch (error:Error)
        {
            BuilderAlert.show(ResourceManager.getInstance().getString('BuilderStrings', 'startup.couldNotCreateCustomDirectories'), ResourceManager.getInstance().getString('BuilderStrings', 'error'));
        }
    }

    private function loadUserPreferences():void
    {
        if (Log.isInfo())
        {
            LOG.info('Loading user preferences...');
        }

        migratePreviousSettingsFolder();
        const so:SharedObject = SharedObject.getLocal(Model.USER_PREF);

        startupSettings = new Settings();

        startupSettings.webServerURL = so.data.baseURL;
        startupSettings.webServerFolder = so.data.baseLoc;
        startupSettings.locale = so.data.locale ? so.data.locale : getPreferredLocale();
        startupSettings.bingKey = so.data.bingKey;
        startupSettings.proxyURL = so.data.httpProxy;

        if (so.data.hasOwnProperty("userPortalURL"))
        {
            //updated property for v3.1+
            startupSettings.portalURL = so.data.userPortalURL;
            startupSettings.geocodeURL = so.data.geocodeURL;
            startupSettings.directionsURL = so.data.directionsURL;
            startupSettings.printTaskURL = so.data.printTaskURL;
        }
        else
        {
            startupSettings.portalURL = (so.data.portalURL) ? so.data.portalURL : PortalModel.DEFAULT_PORTAL_URL;
        }

        if (so.data.hasOwnProperty("userGeometryServiceURL"))
        {
            //updated property for v3.1+
            startupSettings.geometryServiceURL = so.data.userGeometryServiceURL;
        }
        else
        {
            startupSettings.geometryServiceURL = so.data.userGeometryServiceURL = (so.data.geometryServiceURL) ? so.data.geometryServiceURL : "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer";
        }

        if (so.data.hasOwnProperty("isTutorialModeEnabled"))
        {
            startupSettings.isTutorialModeEnabled = so.data.isTutorialModeEnabled;
        }
        else if (so.data.tutorialModeSettings)
        {
            startupSettings.isTutorialModeEnabled = so.data.tutorialModeSettings.isTutorialModeEnabled;
        }

        so.close();

        if (!startupSettings.webServerFolder)
        {
            if (Capabilities.os.toLowerCase().indexOf('win') > -1)
            {
                startupSettings.webServerFolder = 'C:\\inetpub\\wwwroot\\flexviewers';
            }
            else if (Capabilities.os.toLowerCase().indexOf('mac') > -1)
            {
                startupSettings.webServerFolder = File.userDirectory.nativePath + '/Sites/flexviewers';
            }
            else if (Capabilities.os.toLowerCase().indexOf('linux') > -1)
            {
                startupSettings.webServerFolder = '/var/httpd/wwwroot/flexviewers'; // TODO - check this !!
            }
        }

        if (startupSettings.webServerURL)
        {
            applySettings();
        }
        else
        {
            tryGetHostName();
        }
    }

    private function migratePreviousSettingsFolder():void
    {
        var previousBuilderSettingsFolder:File =
            File.applicationStorageDirectory.resolvePath("#SharedObjects/AppBuilder.swf/");

        if (!previousBuilderSettingsFolder.exists)
        {
            return;
        }

        var filesOrFolders:Array = previousBuilderSettingsFolder.getDirectoryListing();

        if (filesOrFolders.length == 0)
        {
            return;
        }

        if (Log.isInfo())
        {
            LOG.info('Transferring previous settings folder');
        }

        var currentBuilderSettingsFolder:File =
            File.applicationStorageDirectory.resolvePath("#SharedObjects/Builder.swf/");

        try
        {
            for each (var fileOrFolder:File in filesOrFolders)
            {
                if (Log.isInfo())
                {
                    LOG.info('Transferring {0}', fileOrFolder.name);
                }
                fileOrFolder.moveTo(currentBuilderSettingsFolder.resolvePath(fileOrFolder.name),
                                    true);
            }
        }
        catch (error:Error)
        {
            if (Log.isInfo())
            {
                LOG.info('Could not transfer previous settings folder: {0} - {1}',
                         error.errorID, error.toString());
            }
        }
    }

    private function applySettings():void
    {
        Model.instance.importSettings(startupSettings);
        startupSettings = null;
    }

    private function tryGetHostName():void
    {
        MachineDisplayName.getInstance().resolve(new AsyncResponder(result, fault));

        function result(hostname:String, token:Object):void
        {
            initBaseURL(hostname.toLowerCase());
            applySettings();
        }

        function fault(fault:Object, token:Object):void
        {
            initBaseURL("localhost");
            applySettings();
        }
    }

    private function initBaseURL(hostname:String):void
    {
        if (Capabilities.os.toLowerCase().indexOf('win') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/flexviewers';
        }
        else if (Capabilities.os.toLowerCase().indexOf('mac') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/~' + File.userDirectory.name + '/flexviewers';
        }
        else if (Capabilities.os.toLowerCase().indexOf('linux') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/flexviewers'; // TODO - check this !!
        }
    }

    private function getPreferredLocale():String
    {
        const preferredLocales:Array = ResourceManager.getInstance().getPreferredLocaleChain();
        return (preferredLocales.length > 0) ? preferredLocales[0] : 'en_US';
    }

    private function loadWebMapSearchHistory():void
    {
        if (Log.isInfo())
        {
            LOG.info("Loading web map search history");
        }

        const so:SharedObject = SharedObject.getLocal(Model.USER_PREF);
        var historyString:String = so.data.webMapSearchHistory;
        if (historyString != null)
        {
            Model.instance.webMapSearchHistory = historyString.split("##");
        }
        so.close();
    }

    private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
    {
        event.preventDefault();

        if (Log.isFatal())
        {
            if (event.error is Error) //could be ErrorEvent
            {
                LOG.fatal('Uncaught error: {0}', event.error.getStackTrace());
            }
        }

        const logFile:File = File.applicationStorageDirectory.resolvePath(LogFileTarget.LOG_FILE_NAME);
        const errorContent:String = ResourceManager.getInstance().getString('BuilderStrings', 'unknownErrorMessage',
                                                                            [ event.error.toString(), logFile.nativePath ]);
        const errorPopUp:UnknownErrorPopUp = new UnknownErrorPopUp();
        errorPopUp.errorContent = errorContent;
        errorPopUp.open(FlexGlobals.topLevelApplication as DisplayObjectContainer, true);
    }

    private function setStatusAndAlert(text:String):void
    {
        Model.instance.status = text;
        BuilderAlert.show(text, ResourceManager.getInstance().getString('BuilderStrings', 'error'));
    }

    protected function widgetTypeLoader_completeHandler(event:Event):void
    {
        (event.currentTarget as StartupWidgetTypeLoader).removeEventListener(Event.COMPLETE, widgetTypeLoader_completeHandler);
        initIdentityManager();
    }

    private function initIdentityManager():void
    {
        var portalURL:String = PortalModel.getInstance().portalURL;
        var idManager:IdentityManager = IdentityManager.instance;

        idManager.enabled = true;

        if (PortalModel.getInstance().isAGO(portalURL))
        {
            idManager.addEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
            PortalModel.getInstance().registerOAuthPortal(portalURL);
            idManager.getCredential(portalURL, false, new Responder(getCredentialOutcomeHandler,
                                                                    getCredentialOutcomeHandler));

            function getCredentialOutcomeHandler(outcome:Object):void
            {
                idManager.removeEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
                validateSettings();
            }

            function showOAuthWebViewHandler(event:IdentityManagerEvent):void
            {
                idManager.removeEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
                event.preventDefault();
                idManager.setCredentialForCurrentSignIn(null);
                validateSettings();
            }
        }
        else
        {
            validateSettings();
        }
    }

    private function validateSettings():void
    {
        AppEvent.dispatch(AppEvent.SAVE_SETTINGS, Model.instance.exportSettings());
    }
}
}

////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008-2013 Esri. All Rights Reserved.
//
// Licensed 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 com.esri.builder.controllers
{

import com.esri.ags.components.IdentityManager;
import com.esri.ags.events.IdentityManagerEvent;
import com.esri.builder.components.LogFileTarget;
import com.esri.builder.components.ToolTip;
import com.esri.builder.controllers.supportClasses.MachineDisplayName;
import com.esri.builder.controllers.supportClasses.Settings;
import com.esri.builder.controllers.supportClasses.StartupWidgetTypeLoader;
import com.esri.builder.controllers.supportClasses.WellKnownDirectories;
import com.esri.builder.eventbus.AppEvent;
import com.esri.builder.model.Model;
import com.esri.builder.model.PortalModel;
import com.esri.builder.supportClasses.LogUtil;
import com.esri.builder.views.BuilderAlert;
import com.esri.builder.views.popups.UnknownErrorPopUp;

import flash.display.DisplayObjectContainer;
import flash.events.Event;
import flash.events.UncaughtErrorEvent;
import flash.filesystem.File;
import flash.net.SharedObject;
import flash.net.URLRequestDefaults;
import flash.system.Capabilities;

import mx.core.FlexGlobals;
import mx.logging.ILogger;
import mx.logging.Log;
import mx.managers.ToolTipManager;
import mx.resources.ResourceManager;
import mx.rpc.AsyncResponder;
import mx.rpc.Responder;

import spark.components.WindowedApplication;

public final class ApplicationCompleteController
{
    private static const LOG:ILogger = LogUtil.createLogger(ApplicationCompleteController);

    private var widgetTypeLoader:StartupWidgetTypeLoader;

    private var startupSettings:Settings;

    public function ApplicationCompleteController()
    {
        AppEvent.addListener(AppEvent.APPLICATION_COMPLETE, onApplicationComplete, false, 0, true);
    }

    private function onApplicationComplete(event:AppEvent):void
    {
        applicationComplete(event.data as WindowedApplication);
        Model.instance.config.isDirty = false;
    }

    private function applicationComplete(app:WindowedApplication):void
    {
        if (Log.isInfo())
        {
            LOG.info('Starting up application.');
        }

        exportDependenciesToAppStorage();
        loadUserPreferences();
        loadWebMapSearchHistory();
        // Disable HTTP cache for HTML component
        URLRequestDefaults.cacheResponse = false;

        // Setup some XML global properties
        XML.ignoreComments = true;
        XML.ignoreWhitespace = true;
        XML.prettyIndent = 4;

        ToolTipManager.toolTipClass = ToolTip;

        // Can only have access to 'loaderInfo' when the app is complete.
        app.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);

        widgetTypeLoader = new StartupWidgetTypeLoader();
        widgetTypeLoader.addEventListener(Event.COMPLETE, widgetTypeLoader_completeHandler);
        widgetTypeLoader.loadWidgetTypes();
    }

    private function exportDependenciesToAppStorage():void
    {
        try
        {
            if (Log.isInfo())
            {
                LOG.info('Creating required folders.');
            }

            WellKnownDirectories.getInstance().customFlexViewer.createDirectory();
            WellKnownDirectories.getInstance().customModules.createDirectory();
        }
        catch (error:Error)
        {
            BuilderAlert.show(ResourceManager.getInstance().getString('BuilderStrings', 'startup.couldNotCreateCustomDirectories'), ResourceManager.getInstance().getString('BuilderStrings', 'error'));
        }
    }

    private function loadUserPreferences():void
    {
        if (Log.isInfo())
        {
            LOG.info('Loading user preferences...');
        }

        migratePreviousSettingsFolder();
        const so:SharedObject = SharedObject.getLocal(Model.USER_PREF);

        startupSettings = new Settings();

        startupSettings.webServerURL = so.data.baseURL;
        startupSettings.webServerFolder = so.data.baseLoc;
        startupSettings.locale = so.data.locale ? so.data.locale : getPreferredLocale();
        startupSettings.bingKey = so.data.bingKey;
        startupSettings.proxyURL = so.data.httpProxy;

        if (so.data.hasOwnProperty("userPortalURL"))
        {
            //updated property for v3.1+
            startupSettings.portalURL = so.data.userPortalURL;
            startupSettings.geocodeURL = so.data.geocodeURL;
            startupSettings.directionsURL = so.data.directionsURL;
            startupSettings.printTaskURL = so.data.printTaskURL;
        }
        else
        {
            startupSettings.portalURL = (so.data.portalURL) ? so.data.portalURL : PortalModel.DEFAULT_PORTAL_URL;
        }

        if (so.data.hasOwnProperty("userGeometryServiceURL"))
        {
            //updated property for v3.1+
            startupSettings.geometryServiceURL = so.data.userGeometryServiceURL;
        }
        else
        {
            startupSettings.geometryServiceURL = so.data.userGeometryServiceURL = (so.data.geometryServiceURL) ? so.data.geometryServiceURL : "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer";
        }

        if (so.data.hasOwnProperty("isTutorialModeEnabled"))
        {
            startupSettings.isTutorialModeEnabled = so.data.isTutorialModeEnabled;
        }
        else if (so.data.tutorialModeSettings)
        {
            startupSettings.isTutorialModeEnabled = so.data.tutorialModeSettings.isTutorialModeEnabled;
        }

        so.close();

        if (!startupSettings.webServerFolder)
        {
            if (Capabilities.os.toLowerCase().indexOf('win') > -1)
            {
                startupSettings.webServerFolder = 'C:\\inetpub\\wwwroot\\flexviewers';
            }
            else if (Capabilities.os.toLowerCase().indexOf('mac') > -1)
            {
                startupSettings.webServerFolder = File.userDirectory.nativePath + '/Sites/flexviewers';
            }
            else if (Capabilities.os.toLowerCase().indexOf('linux') > -1)
            {
                startupSettings.webServerFolder = '/var/httpd/wwwroot/flexviewers'; // TODO - check this !!
            }
        }

        if (startupSettings.webServerURL)
        {
            applySettings();
        }
        else
        {
            tryGetHostName();
        }
    }

    private function migratePreviousSettingsFolder():void
    {
        var previousBuilderSettingsFolder:File =
            File.applicationStorageDirectory.resolvePath("#SharedObjects/AppBuilder.swf/");

        if (!previousBuilderSettingsFolder.exists)
        {
            return;
        }

        var filesOrFolders:Array = previousBuilderSettingsFolder.getDirectoryListing();

        if (filesOrFolders.length == 0)
        {
            return;
        }

        if (Log.isInfo())
        {
            LOG.info('Transferring previous settings folder');
        }

        var currentBuilderSettingsFolder:File =
            File.applicationStorageDirectory.resolvePath("#SharedObjects/Builder.swf/");

        try
        {
            for each (var fileOrFolder:File in filesOrFolders)
            {
                if (Log.isInfo())
                {
                    LOG.info('Transferring {0}', fileOrFolder.name);
                }
                fileOrFolder.moveTo(currentBuilderSettingsFolder.resolvePath(fileOrFolder.name),
                                    true);
            }
        }
        catch (error:Error)
        {
            if (Log.isInfo())
            {
                LOG.info('Could not transfer previous settings folder: {0} - {1}',
                         error.errorID, error.toString());
            }
        }
    }

    private function applySettings():void
    {
        Model.instance.importSettings(startupSettings);
        startupSettings = null;
    }

    private function tryGetHostName():void
    {
        MachineDisplayName.getInstance().resolve(new AsyncResponder(result, fault));

        function result(hostname:String, token:Object):void
        {
            initBaseURL(hostname.toLowerCase());
            applySettings();
        }

        function fault(fault:Object, token:Object):void
        {
            initBaseURL("localhost");
            applySettings();
        }
    }

    private function initBaseURL(hostname:String):void
    {
        if (Capabilities.os.toLowerCase().indexOf('win') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/flexviewers';
        }
        else if (Capabilities.os.toLowerCase().indexOf('mac') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/~' + File.userDirectory.name + '/flexviewers';
        }
        else if (Capabilities.os.toLowerCase().indexOf('linux') > -1)
        {
            startupSettings.webServerURL = 'http://' + hostname + '/flexviewers'; // TODO - check this !!
        }
    }

    private function getPreferredLocale():String
    {
        const preferredLocales:Array = ResourceManager.getInstance().getPreferredLocaleChain();
        return (preferredLocales.length > 0) ? preferredLocales[0] : 'en_US';
    }

    private function loadWebMapSearchHistory():void
    {
        if (Log.isInfo())
        {
            LOG.info("Loading web map search history");
        }

        const so:SharedObject = SharedObject.getLocal(Model.USER_PREF);
        var historyString:String = so.data.webMapSearchHistory;
        if (historyString != null)
        {
            Model.instance.webMapSearchHistory = historyString.split("##");
        }
        so.close();
    }

    private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
    {
        event.preventDefault();

        if (Log.isFatal())
        {
            if (event.error is Error) //could be ErrorEvent
            {
                LOG.fatal('Uncaught error: {0}', event.error.getStackTrace());
            }
        }

        const logFile:File = File.applicationStorageDirectory.resolvePath(LogFileTarget.LOG_FILE_NAME);
        const errorContent:String = ResourceManager.getInstance().getString('BuilderStrings', 'unknownErrorMessage',
                                                                            [ event.error.toString(), logFile.nativePath ]);
        const errorPopUp:UnknownErrorPopUp = new UnknownErrorPopUp();
        errorPopUp.errorContent = errorContent;
        errorPopUp.open(FlexGlobals.topLevelApplication as DisplayObjectContainer, true);
    }

    protected function widgetTypeLoader_completeHandler(event:Event):void
    {
        (event.currentTarget as StartupWidgetTypeLoader).removeEventListener(Event.COMPLETE, widgetTypeLoader_completeHandler);
        initIdentityManager();
    }

    private function initIdentityManager():void
    {
        var portalURL:String = PortalModel.getInstance().portalURL;
        var idManager:IdentityManager = IdentityManager.instance;

        idManager.enabled = true;

        if (PortalModel.getInstance().isAGO(portalURL))
        {
            idManager.addEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
            PortalModel.getInstance().registerOAuthPortal(portalURL);
            idManager.getCredential(portalURL, false, new Responder(getCredentialOutcomeHandler,
                                                                    getCredentialOutcomeHandler));

            function getCredentialOutcomeHandler(outcome:Object):void
            {
                idManager.removeEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
                validateSettings();
            }

            function showOAuthWebViewHandler(event:IdentityManagerEvent):void
            {
                idManager.removeEventListener(IdentityManagerEvent.SHOW_OAUTH_WEB_VIEW, showOAuthWebViewHandler);
                event.preventDefault();
                idManager.setCredentialForCurrentSignIn(null);
                validateSettings();
            }
        }
        else
        {
            validateSettings();
        }
    }

    private function validateSettings():void
    {
        AppEvent.dispatch(AppEvent.SAVE_SETTINGS, Model.instance.exportSettings());
    }
}
}

Remove unused method.

Remove unused method.


////////////////////////////////////////////////////////////////////////////////
//
//  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
{

/**
 *  @private
 *  This class is used to link additional classes into rpc.swc
 *  beyond those that are found by dependecy analysis starting
 *  from the classes specified in manifest.xml.
 */
internal class FlexJSUIClasses
{
    import org.apache.flex.html.staticControls.beads.AlertView; AlertView;
    import org.apache.flex.html.staticControls.beads.CheckBoxView; CheckBoxView;
    import org.apache.flex.html.staticControls.beads.ComboBoxView; ComboBoxView;
    import org.apache.flex.html.staticControls.beads.ContainerView; ContainerView;
    import org.apache.flex.html.staticControls.beads.ControlBarMeasurementBead; ControlBarMeasurementBead;
	import org.apache.flex.html.staticControls.beads.CSSTextButtonView; CSSTextButtonView;
    import org.apache.flex.html.staticControls.beads.DropDownListView; DropDownListView;
    import org.apache.flex.html.staticControls.beads.ListView; ListView;
    import org.apache.flex.html.staticControls.beads.NumericStepperView; NumericStepperView;
    import org.apache.flex.html.staticControls.beads.PanelView; PanelView;
	import org.apache.flex.html.staticControls.beads.RadioButtonView; RadioButtonView;
	import org.apache.flex.html.staticControls.beads.SimpleAlertView; SimpleAlertView;
    import org.apache.flex.html.staticControls.beads.SpinnerView; SpinnerView;
    import org.apache.flex.html.staticControls.beads.TextButtonMeasurementBead; TextButtonMeasurementBead;
	import org.apache.flex.html.staticControls.beads.TextFieldLabelMeasurementBead; TextFieldLabelMeasurementBead;
    import org.apache.flex.html.staticControls.beads.TextAreaView; TextAreaView;
    import org.apache.flex.html.staticControls.beads.TextButtonView; TextButtonView;
    import org.apache.flex.html.staticControls.beads.TextFieldView; TextFieldView;
    import org.apache.flex.html.staticControls.beads.TextInputView; TextInputView;
    import org.apache.flex.html.staticControls.beads.TextInputWithBorderView; TextInputWithBorderView;
    import org.apache.flex.html.staticControls.beads.TitleBarMeasurementBead; TitleBarMeasurementBead;
    import org.apache.flex.html.staticControls.beads.models.AlertModel; AlertModel;
    import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
    import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
    import org.apache.flex.html.staticControls.beads.models.PanelModel; PanelModel;
    import org.apache.flex.html.staticControls.beads.models.SpinnerModel; SpinnerModel;
	import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
    import org.apache.flex.html.staticControls.beads.models.TitleBarModel; TitleBarModel;
	import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;
	import org.apache.flex.html.staticControls.beads.models.ValueToggleButtonModel; ValueToggleButtonModel;
    import org.apache.flex.html.staticControls.beads.controllers.DropDownListController; DropDownListController;
    import org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController; ListSingleSelectionMouseController;
    import org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController; ItemRendererMouseController;
    import org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalScrollingLayout; NonVirtualVerticalScrollingLayout;
    import org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData; TextItemRendererFactoryForArrayData;
    import org.apache.flex.core.ItemRendererClassFactory; ItemRendererClassFactory;
	import org.apache.flex.events.CustomEvent; CustomEvent;
	import org.apache.flex.events.Event; Event;
	import org.apache.flex.utils.Timer; Timer;
    import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl;
}

}

////////////////////////////////////////////////////////////////////////////////
//
//  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
{

/**
 *  @private
 *  This class is used to link additional classes into rpc.swc
 *  beyond those that are found by dependecy analysis starting
 *  from the classes specified in manifest.xml.
 */
internal class FlexJSUIClasses
{
    import org.apache.flex.html.staticControls.beads.AlertView; AlertView;
    import org.apache.flex.html.staticControls.beads.CheckBoxView; CheckBoxView;
    import org.apache.flex.html.staticControls.beads.ComboBoxView; ComboBoxView;
    import org.apache.flex.html.staticControls.beads.ContainerView; ContainerView;
    import org.apache.flex.html.staticControls.beads.ControlBarMeasurementBead; ControlBarMeasurementBead;
	import org.apache.flex.html.staticControls.beads.CSSTextButtonView; CSSTextButtonView;
    import org.apache.flex.html.staticControls.beads.DropDownListView; DropDownListView;
    import org.apache.flex.html.staticControls.beads.ListView; ListView;
    import org.apache.flex.html.staticControls.beads.NumericStepperView; NumericStepperView;
    import org.apache.flex.html.staticControls.beads.PanelView; PanelView;
	import org.apache.flex.html.staticControls.beads.RadioButtonView; RadioButtonView;
    import org.apache.flex.html.staticControls.beads.ScrollBarView; ScrollBarView;
	import org.apache.flex.html.staticControls.beads.SimpleAlertView; SimpleAlertView;
    import org.apache.flex.html.staticControls.beads.SpinnerView; SpinnerView;
    import org.apache.flex.html.staticControls.beads.TextButtonMeasurementBead; TextButtonMeasurementBead;
	import org.apache.flex.html.staticControls.beads.TextFieldLabelMeasurementBead; TextFieldLabelMeasurementBead;
    import org.apache.flex.html.staticControls.beads.TextAreaView; TextAreaView;
    import org.apache.flex.html.staticControls.beads.TextButtonView; TextButtonView;
    import org.apache.flex.html.staticControls.beads.TextFieldView; TextFieldView;
    import org.apache.flex.html.staticControls.beads.TextInputView; TextInputView;
    import org.apache.flex.html.staticControls.beads.TextInputWithBorderView; TextInputWithBorderView;
    import org.apache.flex.html.staticControls.beads.TitleBarMeasurementBead; TitleBarMeasurementBead;
    import org.apache.flex.html.staticControls.beads.models.AlertModel; AlertModel;
    import org.apache.flex.html.staticControls.beads.models.ArraySelectionModel; ArraySelectionModel;
    import org.apache.flex.html.staticControls.beads.models.ComboBoxModel; ComboBoxModel;
    import org.apache.flex.html.staticControls.beads.models.PanelModel; PanelModel;
    import org.apache.flex.html.staticControls.beads.models.SpinnerModel; SpinnerModel;
	import org.apache.flex.html.staticControls.beads.models.TextModel; TextModel;
    import org.apache.flex.html.staticControls.beads.models.TitleBarModel; TitleBarModel;
	import org.apache.flex.html.staticControls.beads.models.ToggleButtonModel; ToggleButtonModel;
	import org.apache.flex.html.staticControls.beads.models.ValueToggleButtonModel; ValueToggleButtonModel;
    import org.apache.flex.html.staticControls.beads.controllers.AlertController; AlertController;
    import org.apache.flex.html.staticControls.beads.controllers.DropDownListController; DropDownListController;
    import org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController; ItemRendererMouseController;
    import org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController; ListSingleSelectionMouseController;
    import org.apache.flex.html.staticControls.beads.controllers.SpinnerMouseController; SpinnerMouseController;
    import org.apache.flex.html.staticControls.beads.controllers.VScrollBarMouseController; VScrollBarMouseController;
    import org.apache.flex.html.staticControls.beads.layouts.NonVirtualVerticalScrollingLayout; NonVirtualVerticalScrollingLayout;
    import org.apache.flex.html.staticControls.beads.layouts.VScrollBarLayout; VScrollBarLayout;
    import org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData; TextItemRendererFactoryForArrayData;
    import org.apache.flex.core.ItemRendererClassFactory; ItemRendererClassFactory;
	import org.apache.flex.events.CustomEvent; CustomEvent;
	import org.apache.flex.events.Event; Event;
	import org.apache.flex.utils.Timer; Timer;
    import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl;

    import mx.states.AddItems; AddItems;
    import mx.states.SetProperty; SetProperty;
    import mx.states.State; State;
}

}

Add mx state shims to SWC

Add mx state shims to SWC


package aerys.minko.type.math
{
	import aerys.minko.ns.minko_math;
	import aerys.minko.type.Factory;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.IWatchable;

	import flash.geom.Vector3D;

	final public class Vector4 implements IWatchable
	{
		use namespace minko_math;

		public static const X_AXIS				: Vector4	= new Vector4(1., 0., 0.);
		public static const Y_AXIS				: Vector4	= new Vector4(0., 1., 0.);
		public static const Z_AXIS				: Vector4	= new Vector4(0., 0., 1.);
		public static const ZERO				: Vector4	= new Vector4(0., 0., 0., 0.);
		public static const ONE					: Vector4	= new Vector4(1., 1., 1., 1.);
		public static const FORWARD				: Vector4	= Z_AXIS;
		public static const BACKWARD			: Vector4	= new Vector4(0., 0., -1.);
		public static const LEFT				: Vector4	= new Vector4(-1, 0., 0.);
		public static const RIGHT				: Vector4	= new Vector4(1, 0., 0.);
		public static const UP					: Vector4	= Y_AXIS;
		public static const DOWN				: Vector4	= new Vector4(0, -1., 0.);

		private static const FACTORY			: Factory	= Factory.getFactory(Vector4);

		private static const UPDATE_NONE		: uint		= 0;
		private static const UPDATE_LENGTH		: uint		= 1;
		private static const UPDATE_LENGTH_SQ	: uint		= 2;
		private static const UPDATE_ALL			: uint		= 3; // UPDATE_LENGTH | UPDATE_LENGTH_SQ;

		private static const DATA_DESCRIPTOR	: Object	= {
			'x'	: 'x',
			'y'	: 'y',
			'z'	: 'z',
			'w'	: 'w'
		};

		minko_math var _vector	: Vector3D	= new Vector3D();

		private var _update		: uint		= 0;

		private var _length		: Number	= 0.;
		private var _lengthSq	: Number	= 0.;

		private var _locked		: Boolean	= false;
		private var _changed	: Signal	= new Signal('Vector4.changed');

		public function get x()	: Number
		{
			return _vector.x;
		}
		public function set x(value : Number) : void
		{
			if (value != _vector.x)
			{
				_vector.x = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get y()	: Number
		{
			return _vector.y;
		}
		public function set y(value : Number) : void
		{
			if (value != _vector.y)
			{
				_vector.y = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get z() : Number
		{
			return _vector.z;
		}
		public function set z(value : Number) : void
		{
			if (value != _vector.z)
			{
				_vector.z = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get w()	: Number
		{
			return _vector.w;
		}
		public function set w(value : Number) : void
		{
			if (value != _vector.w)
			{
				_vector.w = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get lengthSquared()	: Number
		{
			if (_update & UPDATE_LENGTH_SQ)
			{
				_update ^= UPDATE_LENGTH_SQ;
				_lengthSq = _vector.x * _vector.x + _vector.y * _vector.y
							+ _vector.z * _vector.z;
			}

			return _lengthSq;
		}

		public function get length() : Number
		{
			if (_update & UPDATE_LENGTH)
			{
				_update ^= UPDATE_LENGTH;
				_length = Math.sqrt(lengthSquared);
			}

			return _length;
		}

		public function get locked() : Boolean
		{
			return _locked;
		}

		public function get changed() : Signal
		{
			return _changed;
		}

		public function Vector4(x 	: Number	= 0.,
								y	: Number	= 0.,
								z	: Number	= 0.,
								w 	: Number	= 1.)
		{
			_vector.x = x;
			_vector.y = y;
			_vector.z = z;
			_vector.w = w;

			_update = UPDATE_ALL;
		}

		public static function add(u 	: Vector4,
								   v 	: Vector4,
								   out	: Vector4 = null) : Vector4
		{
			out ||= new Vector4();
			out.copyFrom(u);

			return out.incrementBy(v);
		}

		public static function subtract(u 	: Vector4,
										v 	: Vector4,
										out : Vector4 = null) : Vector4
		{
			out ||= new Vector4();
			out.copyFrom(u);

			return out.decrementBy(v);
		}

		public static function dotProduct(u : Vector4, v : Vector4) : Number
		{
			return u._vector.dotProduct(v._vector);
		}

		public static function crossProduct(u : Vector4, v : Vector4, out : Vector4 = null) : Vector4
		{
			out ||= FACTORY.create() as Vector4;

			out.set(
				u._vector.y * v._vector.z - v._vector.y * u._vector.z,
				u._vector.z * v._vector.x - v._vector.z * u._vector.x,
				u._vector.x * v._vector.y - v._vector.x * u._vector.y
			);

			return out;
		}

		public static function distance(u : Vector4, v : Vector4) : Number
		{
			return Vector3D.distance(u._vector, v._vector);
		}

		public function copyFrom(source : Vector4) : Vector4
		{
            var sourceVector : Vector3D = source._vector;

			return set(sourceVector.x, sourceVector.y, sourceVector.z, sourceVector..w);
		}

		public function incrementBy(vector : Vector4) : Vector4
		{
			_vector.incrementBy(vector._vector);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function decrementBy(vector : Vector4) : Vector4
		{
			_vector.decrementBy(vector._vector);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function scaleBy(scale : Number) : Vector4
		{
			_vector.scaleBy(scale);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function lerp(target : Vector4, ratio : Number) : Vector4
		{
			if (ratio == 1.)
				return copyFrom(target);

			if (ratio != 0.)
			{
				var x : Number = _vector.x;
				var y : Number = _vector.y;
				var z : Number = _vector.z;
				var w : Number = _vector.w;

				set(
					x + (target._vector.x - x) * ratio,
					y + (target._vector.y - y) * ratio,
					z + (target._vector.z - z) * ratio,
					w + (target._vector.w - w) * ratio
				);
			}

			return this;
		}

		public function equals(v : Vector4, allFour : Boolean = false, tolerance : Number = 0.) : Boolean
		{
			return tolerance
				? _vector.nearEquals(v._vector, tolerance, allFour)
				: _vector.equals(v._vector, allFour);
		}

		public function project() : Vector4
		{
			_vector.x /= _vector.w;
			_vector.y /= _vector.w;
			_vector.z /= _vector.w;

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function normalize() : Vector4
		{
			var l : Number = length;

			if (l != 0.)
			{
				_vector.x /= l;
				_vector.y /= l;
				_vector.z /= l;

				_length = 1.;
				_lengthSq = 1.;

				_update = UPDATE_NONE;
				_changed.execute(this);
			}

			return this;
		}

		public function crossProduct(vector : Vector4) : Vector4
		{
			var x : Number = _vector.x;
			var y : Number = _vector.y;
			var z : Number = _vector.z;

			_vector.x = y * vector._vector.z - vector._vector.y * z;
			_vector.y = z * vector._vector.x - vector._vector.z * x;
			_vector.z = x * vector._vector.y - vector._vector.x * y;

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function getVector3D() : Vector3D
		{
			return _vector.clone();
		}

		public function set(x : Number,
							y : Number,
							z : Number,
							w : Number = 1.) : Vector4
		{
			if (x != _vector.x || y != _vector.y || z != _vector.z || w != _vector.w)
			{
				_vector.setTo(x, y, z);
				_vector.w = w;

				_update = UPDATE_ALL;
				if (!_locked)
					_changed.execute(this);
			}

			return this;
		}

		public function toString() : String
		{
			return '(' + _vector.x + ', ' + _vector.y + ', ' + _vector.z + ', ' + _vector.w + ')';
		}

		public static function scale(v : Vector4, s : Number, out : Vector4 = null) : Vector4
		{
			out ||= FACTORY.create() as Vector4;
			out.set(v._vector.x * s, v._vector.y * s, v._vector.z * s, v._vector.w * s);

			return out;
		}

		public function toVector3D(out : Vector3D = null) : Vector3D
		{
			if (!out)
				return _vector.clone();

			out.x = _vector.x;
			out.y = _vector.y;
			out.z = _vector.z;
			out.w = _vector.w;

			return out;
		}

		public function lock() : void
		{
			_locked = true;
		}

		public function unlock() : void
		{
			_locked = false;
			_changed.execute(this);
		}

		public function clone() : Vector4
		{
			return new Vector4(_vector.x, _vector.y, _vector.z, _vector.w);
		}
	}
}

package aerys.minko.type.math
{
	import aerys.minko.ns.minko_math;
	import aerys.minko.type.Factory;
	import aerys.minko.type.Signal;
	import aerys.minko.type.binding.IWatchable;

	import flash.geom.Vector3D;

	final public class Vector4 implements IWatchable
	{
		use namespace minko_math;

		public static const X_AXIS				: Vector4	= new Vector4(1., 0., 0.);
		public static const Y_AXIS				: Vector4	= new Vector4(0., 1., 0.);
		public static const Z_AXIS				: Vector4	= new Vector4(0., 0., 1.);
		public static const ZERO				: Vector4	= new Vector4(0., 0., 0., 0.);
		public static const ONE					: Vector4	= new Vector4(1., 1., 1., 1.);
		public static const FORWARD				: Vector4	= Z_AXIS;
		public static const BACKWARD			: Vector4	= new Vector4(0., 0., -1.);
		public static const LEFT				: Vector4	= new Vector4(-1, 0., 0.);
		public static const RIGHT				: Vector4	= new Vector4(1, 0., 0.);
		public static const UP					: Vector4	= Y_AXIS;
		public static const DOWN				: Vector4	= new Vector4(0, -1., 0.);

		private static const FACTORY			: Factory	= Factory.getFactory(Vector4);

		private static const UPDATE_NONE		: uint		= 0;
		private static const UPDATE_LENGTH		: uint		= 1;
		private static const UPDATE_LENGTH_SQ	: uint		= 2;
		private static const UPDATE_ALL			: uint		= 3; // UPDATE_LENGTH | UPDATE_LENGTH_SQ;

		private static const DATA_DESCRIPTOR	: Object	= {
			'x'	: 'x',
			'y'	: 'y',
			'z'	: 'z',
			'w'	: 'w'
		};

		minko_math var _vector	: Vector3D	= new Vector3D();

		private var _update		: uint		= 0;

		private var _length		: Number	= 0.;
		private var _lengthSq	: Number	= 0.;

		private var _locked		: Boolean	= false;
		private var _changed	: Signal	= new Signal('Vector4.changed');

		public function get x()	: Number
		{
			return _vector.x;
		}
		public function set x(value : Number) : void
		{
			if (value != _vector.x)
			{
				_vector.x = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get y()	: Number
		{
			return _vector.y;
		}
		public function set y(value : Number) : void
		{
			if (value != _vector.y)
			{
				_vector.y = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get z() : Number
		{
			return _vector.z;
		}
		public function set z(value : Number) : void
		{
			if (value != _vector.z)
			{
				_vector.z = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get w()	: Number
		{
			return _vector.w;
		}
		public function set w(value : Number) : void
		{
			if (value != _vector.w)
			{
				_vector.w = value;
				_update = UPDATE_ALL;

				if (!_locked)
					_changed.execute(this);
			}
		}

		public function get lengthSquared()	: Number
		{
			if (_update & UPDATE_LENGTH_SQ)
			{
				_update ^= UPDATE_LENGTH_SQ;
				_lengthSq = _vector.x * _vector.x + _vector.y * _vector.y
							+ _vector.z * _vector.z;
			}

			return _lengthSq;
		}

		public function get length() : Number
		{
			if (_update & UPDATE_LENGTH)
			{
				_update ^= UPDATE_LENGTH;
				_length = Math.sqrt(lengthSquared);
			}

			return _length;
		}

		public function get locked() : Boolean
		{
			return _locked;
		}

		public function get changed() : Signal
		{
			return _changed;
		}

		public function Vector4(x 	: Number	= 0.,
								y	: Number	= 0.,
								z	: Number	= 0.,
								w 	: Number	= 1.)
		{
			_vector.x = x;
			_vector.y = y;
			_vector.z = z;
			_vector.w = w;

			_update = UPDATE_ALL;
		}

		public static function add(u 	: Vector4,
								   v 	: Vector4,
								   out	: Vector4 = null) : Vector4
		{
			out ||= new Vector4();
			out.copyFrom(u);

			return out.incrementBy(v);
		}

		public static function subtract(u 	: Vector4,
										v 	: Vector4,
										out : Vector4 = null) : Vector4
		{
			out ||= new Vector4();
			out.copyFrom(u);

			return out.decrementBy(v);
		}

		public static function dotProduct(u : Vector4, v : Vector4) : Number
		{
			return u._vector.dotProduct(v._vector);
		}

		public static function crossProduct(u : Vector4, v : Vector4, out : Vector4 = null) : Vector4
		{
			out ||= FACTORY.create() as Vector4;

			out.set(
				u._vector.y * v._vector.z - v._vector.y * u._vector.z,
				u._vector.z * v._vector.x - v._vector.z * u._vector.x,
				u._vector.x * v._vector.y - v._vector.x * u._vector.y
			);

			return out;
		}

		public static function distance(u : Vector4, v : Vector4) : Number
		{
			return Vector3D.distance(u._vector, v._vector);
		}

		public function copyFrom(source : Vector4) : Vector4
		{
            var sourceVector : Vector3D = source._vector;

			return set(sourceVector.x, sourceVector.y, sourceVector.z, sourceVector.w);
		}

		public function incrementBy(vector : Vector4) : Vector4
		{
			_vector.incrementBy(vector._vector);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function decrementBy(vector : Vector4) : Vector4
		{
			_vector.decrementBy(vector._vector);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function scaleBy(scale : Number) : Vector4
		{
			_vector.scaleBy(scale);

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function lerp(target : Vector4, ratio : Number) : Vector4
		{
			if (ratio == 1.)
				return copyFrom(target);

			if (ratio != 0.)
			{
				var x : Number = _vector.x;
				var y : Number = _vector.y;
				var z : Number = _vector.z;
				var w : Number = _vector.w;

				set(
					x + (target._vector.x - x) * ratio,
					y + (target._vector.y - y) * ratio,
					z + (target._vector.z - z) * ratio,
					w + (target._vector.w - w) * ratio
				);
			}

			return this;
		}

		public function equals(v : Vector4, allFour : Boolean = false, tolerance : Number = 0.) : Boolean
		{
			return tolerance
				? _vector.nearEquals(v._vector, tolerance, allFour)
				: _vector.equals(v._vector, allFour);
		}

		public function project() : Vector4
		{
			_vector.x /= _vector.w;
			_vector.y /= _vector.w;
			_vector.z /= _vector.w;

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function normalize() : Vector4
		{
			var l : Number = length;

			if (l != 0.)
			{
				_vector.x /= l;
				_vector.y /= l;
				_vector.z /= l;

				_length = 1.;
				_lengthSq = 1.;

				_update = UPDATE_NONE;
				_changed.execute(this);
			}

			return this;
		}

		public function crossProduct(vector : Vector4) : Vector4
		{
			var x : Number = _vector.x;
			var y : Number = _vector.y;
			var z : Number = _vector.z;

			_vector.x = y * vector._vector.z - vector._vector.y * z;
			_vector.y = z * vector._vector.x - vector._vector.z * x;
			_vector.z = x * vector._vector.y - vector._vector.x * y;

			_update = UPDATE_ALL;
			_changed.execute(this);

			return this;
		}

		public function getVector3D() : Vector3D
		{
			return _vector.clone();
		}

		public function set(x : Number,
							y : Number,
							z : Number,
							w : Number = 1.) : Vector4
		{
			if (x != _vector.x || y != _vector.y || z != _vector.z || w != _vector.w)
			{
				_vector.setTo(x, y, z);
				_vector.w = w;

				_update = UPDATE_ALL;
				if (!_locked)
					_changed.execute(this);
			}

			return this;
		}

		public function toString() : String
		{
			return '(' + _vector.x + ', ' + _vector.y + ', ' + _vector.z + ', ' + _vector.w + ')';
		}

		public static function scale(v : Vector4, s : Number, out : Vector4 = null) : Vector4
		{
			out ||= FACTORY.create() as Vector4;
			out.set(v._vector.x * s, v._vector.y * s, v._vector.z * s, v._vector.w * s);

			return out;
		}

		public function toVector3D(out : Vector3D = null) : Vector3D
		{
			if (!out)
				return _vector.clone();

			out.x = _vector.x;
			out.y = _vector.y;
			out.z = _vector.z;
			out.w = _vector.w;

			return out;
		}

		public function lock() : void
		{
			_locked = true;
		}

		public function unlock() : void
		{
			_locked = false;
			_changed.execute(this);
		}

		public function clone() : Vector4
		{
			return new Vector4(_vector.x, _vector.y, _vector.z, _vector.w);
		}
	}
}

fix typo

fix typo


package aerys.minko.scene.controller
{
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.KeyboardManager;
	import aerys.minko.type.MouseManager;

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

	public class ScriptController extends EnterFrameController
	{
        private var _scene          : Scene;
        private var _started        : Dictionary;
		private var _lastTime		: Number;
		private var _deltaTime		: Number;
		private var _currentTarget	: ISceneNode;
		private var _viewport		: Viewport;

        protected function get scene() : Scene
        {
            return _scene;
        }

		protected function get deltaTime() : Number
		{
			return _deltaTime;
		}

		protected function get keyboard() : KeyboardManager
		{
			return _viewport.keyboardManager;
		}

		protected function get mouse() : MouseManager
		{
			return _viewport.mouseManager;
		}

		protected function get viewport() : Viewport
		{
			return _viewport;
		}

		public function ScriptController(targetType	: Class = null)
		{
			super(targetType);

            initialize();
		}

        protected function initialize() : void
        {
            _started = new Dictionary(true);
        }

        override protected function targetAddedToSceneHandler(target    : ISceneNode,
                                                              scene     : Scene) : void
        {
            super.targetAddedToSceneHandler(target, scene);

            if (_scene && scene != _scene)
                throw new Error(
                    'The same ScriptController instance can not be used in more than one scene ' +
                    'at a time.'
                );

            _scene = scene;
        }

        override protected function targetRemovedFromSceneHandler(target    : ISceneNode,
                                                                  scene     : Scene) : void
        {
            super.targetRemovedFromSceneHandler(target, scene);

            if (getNumTargetsInScene(scene))
                _scene = null;
        }

		override protected function sceneEnterFrameHandler(scene		: Scene,
														   viewport		: Viewport,
														   destination	: BitmapData,
														   time			: Number) : void
		{
			_viewport = viewport;
			_deltaTime = _lastTime - time;
			_lastTime = time;

            beforeUpdate();

			var numTargets : uint = this.numTargets;

			for (var i : uint = 0; i < numTargets; ++i)
            {
                var target : ISceneNode = getTarget(i);

                if (target.scene)
                {
                    if (!_started[target])
                    {
                        _started[target] = true;
                        start(target);
                    }

    				update(target);
                }
                else if (_started[target])
                {
                    _started[target] = false;
                    stop(target);
                }
            }

            afterUpdate();
		}

        /**
         * The 'start' method is called on a script target at the first frame occuring after it
         * has been added to the scene.
         *
         * @param target
         *
         */
		protected function start(target : ISceneNode) : void
		{
			// nothing
		}

        /**
         * The 'beforeUpdate' method is called before each target is updated via the 'update'
         * method.
         *
         */
        protected function beforeUpdate() : void
        {
            // nothing
        }

		protected function update(target : ISceneNode) : void
		{
			// nothing
		}

        /**
         * The 'afterUpdate' method is called after each target has been updated via the 'update'
         * method.
         *
         */
        protected function afterUpdate() : void
        {
            // nothing
        }

        /**
         * The 'start' method is called on a script target at the first frame occuring after it
         * has been removed from the scene.
         *
         * @param target
         *
         */
		protected function stop(target : ISceneNode) : void
		{
			// nothing
		}
	}
}

package aerys.minko.scene.controller
{
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.KeyboardManager;
	import aerys.minko.type.MouseManager;

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

	public class ScriptController extends EnterFrameController
	{
        private var _scene          : Scene;
        private var _started        : Dictionary;
		private var _lastTime		: Number;
		private var _deltaTime		: Number;
		private var _currentTarget	: ISceneNode;
		private var _viewport		: Viewport;

        protected function get scene() : Scene
        {
            return _scene;
        }

		protected function get deltaTime() : Number
		{
			return _deltaTime;
		}

		protected function get keyboard() : KeyboardManager
		{
			return _viewport.keyboardManager;
		}

		protected function get mouse() : MouseManager
		{
			return _viewport.mouseManager;
		}

		protected function get viewport() : Viewport
		{
			return _viewport;
		}

		public function ScriptController(targetType	: Class = null)
		{
			super(targetType);

            initialize();
		}

        protected function initialize() : void
        {
            _started = new Dictionary(true);
        }

        override protected function targetAddedToSceneHandler(target    : ISceneNode,
                                                              scene     : Scene) : void
        {
            super.targetAddedToSceneHandler(target, scene);

            if (_scene && scene != _scene)
                throw new Error(
                    'The same ScriptController instance can not be used in more than one scene ' +
                    'at a time.'
                );

            _scene = scene;
        }

        override protected function targetRemovedFromSceneHandler(target    : ISceneNode,
                                                                  scene     : Scene) : void
        {
            super.targetRemovedFromSceneHandler(target, scene);

            if (getNumTargetsInScene(scene))
                _scene = null;
        }

		override protected function sceneEnterFrameHandler(scene		: Scene,
														   viewport		: Viewport,
														   destination	: BitmapData,
														   time			: Number) : void
		{
			_viewport = viewport;
			_deltaTime = time - _lastTime;
			_lastTime = time;

            beforeUpdate();

			var numTargets : uint = this.numTargets;

			for (var i : uint = 0; i < numTargets; ++i)
            {
                var target : ISceneNode = getTarget(i);

                if (target.scene)
                {
                    if (!_started[target])
                    {
                        _started[target] = true;
                        start(target);
                    }

    				update(target);
                }
                else if (_started[target])
                {
                    _started[target] = false;
                    stop(target);
                }
            }

            afterUpdate();
		}

        /**
         * The 'start' method is called on a script target at the first frame occuring after it
         * has been added to the scene.
         *
         * @param target
         *
         */
		protected function start(target : ISceneNode) : void
		{
			// nothing
		}

        /**
         * The 'beforeUpdate' method is called before each target is updated via the 'update'
         * method.
         *
         */
        protected function beforeUpdate() : void
        {
            // nothing
        }

		protected function update(target : ISceneNode) : void
		{
			// nothing
		}

        /**
         * The 'afterUpdate' method is called after each target has been updated via the 'update'
         * method.
         *
         */
        protected function afterUpdate() : void
        {
            // nothing
        }

        /**
         * The 'start' method is called on a script target at the first frame occuring after it
         * has been removed from the scene.
         *
         * @param target
         *
         */
		protected function stop(target : ISceneNode) : void
		{
			// nothing
		}
	}
}

fix ScriptController.deltaTime property

fix ScriptController.deltaTime property


package fr.manashield.flex.thex.blocks {
	import fr.manashield.flex.thex.Animation;
	import fr.manashield.flex.thex.events.BlockLandingEvent;
	import fr.manashield.flex.thex.utils.Color;

	import flash.geom.Point;
	/**
	 * @author Morgan Peyre (morgan@peyre.info)
	 * @author Paul Bonnet
	 */
	public class BlockGenerator
	{
		public static var _instance:BlockGenerator;

		/*static*/
		{
			Animation.instance.addEventListener(BlockLandingEvent.LANDING, BlockGenerator.instance.blockLanded);
		}

		public static function get instance():BlockGenerator
		{
			return _instance?_instance:_instance=new BlockGenerator();
		}

		public function spawnBlock(radius:uint = 7, index:int = undefined, addToFallingList:Boolean = true):Block
		{
			var cell:HexagonalCell = HexagonalGrid.instance.cell(new Point(0,radius));

			// Spawn at specified index if any, coerced to [0..6*radius-1]. Else, spawn at random index
			// index = "angular" position on a given hexagonal ring
			var spawnIndex:int = index != undefined ? (index<0 ? (6*radius)+index%(6*radius) : index%(6*radius)) : Math.random()*6*radius;

			for(var i:int=0; i<spawnIndex; ++i)
			{
				cell = cell.clockwiseNeighbor;
			}

			var blockColor:Color;
			if(addToFallingList)
			{
				blockColor = Animation.instance.activeColors()[uint(Math.random()*Animation.instance.activeColors().length)];
			}
			else
			{
				blockColor = Color.RANDOM;
			}

			var newBlock:Block = new Block(cell, blockColor);
			Animation.instance.addBlock(newBlock, addToFallingList);

			if(!addToFallingList)
			{
				newBlock.symbol.alpha = Animation.STATIC_BLOCK_ALPHA;
			}

			return newBlock;
		}

		public function blockLanded(e:BlockLandingEvent):void
		{
			this.spawnBlock();
		}
	}
}

package fr.manashield.flex.thex.blocks {
	import fr.manashield.flex.thex.Animation;
	import fr.manashield.flex.thex.events.BlockLandingEvent;
	import fr.manashield.flex.thex.utils.Color;

	import flash.geom.Point;
	/**
	 * @author Morgan Peyre (morgan@peyre.info)
	 * @author Paul Bonnet
	 */
	public class BlockGenerator
	{
		public static var _instance:BlockGenerator;

		/*static*/
		{
			Animation.instance.addEventListener(BlockLandingEvent.LANDING, BlockGenerator.instance.blockLanded);
		}

		public static function get instance():BlockGenerator
		{
			return _instance?_instance:_instance=new BlockGenerator();
		}

		public function spawnBlock(radius:uint = 7, index:int = undefined, addToFallingList:Boolean = true):Block
		{
			var cell:HexagonalCell = HexagonalGrid.instance.cell(new Point(0,radius));

			// Spawn at specified index if any, coerced to [0..6*radius-1]. Else, spawn at random index
			// index = "angular" position on a given hexagonal ring
			var spawnIndex:int = index != undefined ? (index<0 ? (6*radius)+index%(6*radius) : index%(6*radius)) : Math.random()*6*radius;

			for(var i:int=0; i<spawnIndex; ++i)
			{
				cell = cell.clockwiseNeighbor;
			}

			var blockColor:Color;
			if(addToFallingList)
			{
				blockColor = Animation.instance.activeColors()[uint(Math.random()*Animation.instance.activeColors().length)];
			}
			else
			{
				blockColor = Color.RANDOM;
			}

			var newBlock:Block = new Block(cell, blockColor);
			Animation.instance.addBlock(newBlock, addToFallingList);

			return newBlock;
		}

		public function blockLanded(e:BlockLandingEvent):void
		{
			this.spawnBlock();
		}
	}
}

fix : removed fading effect on static blocks


package aerys.minko.scene.controller.mesh.skinning
{
	import aerys.minko.ns.minko_math;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.controller.IRebindableController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.animation.SkinningMethod;
	import aerys.minko.type.math.Matrix4x4;

	import flash.display.BitmapData;
	import flash.geom.Matrix3D;
	import flash.utils.Dictionary;

	public class SkinningController extends EnterFrameController implements IRebindableController
	{
		private var _skinningHelper		: AbstractSkinningHelper;
		private var _isDirty			: Boolean;

		private var _method				: uint;
		private var _bindShape			: Matrix3D;
		private var _skeletonRoot		: Group;
		private var _joints				: Vector.<Group>;
		private var _invBindMatrices	: Vector.<Matrix3D>;

		public function get skinningMethod() : uint
		{
			return _method;
		}

		public function get bindShape() : Matrix4x4
		{
			var bindShape : Matrix4x4 = new Matrix4x4();
			bindShape.minko_math::_matrix = _bindShape;

			return bindShape;
		}

		public function get skeletonRoot() : Group
		{
			return _skeletonRoot;
		}

		public function get joints() : Vector.<Group>
		{
			return _joints;
		}

		public function get invBindMatrices() : Vector.<Matrix4x4>
		{
			var numMatrices		: uint					= _invBindMatrices.length;
			var invBindMatrices : Vector.<Matrix4x4>	= new Vector.<Matrix4x4>(numMatrices);

			for (var matrixId : uint = 0; matrixId < numMatrices; ++matrixId)
			{
				invBindMatrices[matrixId] = new Matrix4x4();
				invBindMatrices[matrixId].minko_math::_matrix = _invBindMatrices[matrixId];
			}

			return invBindMatrices;
		}

		public function SkinningController(method			: uint,
										   skeletonRoot		: Group,
										   joints			: Vector.<Group>,
										   bindShape		: Matrix4x4,
										   invBindMatrices	: Vector.<Matrix4x4>)
		{
			super(Mesh);

			var numJoints : uint = joints.length;

			_method			 	= method;
			_skeletonRoot		= skeletonRoot;
			_joints				= joints.slice();
			_bindShape			= bindShape.minko_math::_matrix;
			_invBindMatrices	= new Vector.<Matrix3D>(numJoints, true);
			_isDirty			= false;

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_invBindMatrices[jointId] = invBindMatrices[jointId].minko_math::_matrix;

			init();
		}

		private function init() : void
		{
			if (skinningMethod == SkinningMethod.SOFTWARE_MATRIX)
				_skinningHelper = new SoftwareSkinningHelper(_method, _bindShape, _invBindMatrices);
			else
				_skinningHelper = new ShaderSkinningHelper(_method, _bindShape, _invBindMatrices);
		}

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

			if (numTargets == 1)
				subscribeToJoints();

			_isDirty = true;
			_skinningHelper.addMesh(target as Mesh);
		}

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

			if (numTargets == 0)
				unsubscribeFromJoints();

			_skinningHelper.removeMesh(target as Mesh);
		}

		private function jointLocalToWorldChangedHandler(emitter : Matrix4x4) : void
		{
			_isDirty = true;
		}

		public function rebindDependencies(nodeMap			: Dictionary,
										   controllerMap	: Dictionary) : void
		{
			var numJoints	: uint = _joints.length;

			if (numTargets != 0)
				unsubscribeFromJoints();

			if (_joints.indexOf(_skeletonRoot) == -1 && nodeMap[_skeletonRoot])
				_skeletonRoot = nodeMap[_skeletonRoot];

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				if (nodeMap[_joints[jointId]])
					_joints[jointId] = nodeMap[_joints[jointId]];

			if (numTargets != 0)
				subscribeToJoints();

			_isDirty = true;
		}

		private function subscribeToJoints() : void
		{
			var numJoints	: uint = _joints.length;

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_joints[jointId].localToWorld.changed.add(jointLocalToWorldChangedHandler);

			if (_joints.indexOf(_skeletonRoot) == -1)
				_skeletonRoot.localToWorld.changed.add(jointLocalToWorldChangedHandler);
		}

		private function unsubscribeFromJoints() : void
		{
			var numJoints	: uint = _joints.length;

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_joints[jointId].localToWorld.changed.remove(jointLocalToWorldChangedHandler);

			if (_joints.indexOf(_skeletonRoot) == -1)
				_skeletonRoot.localToWorld.changed.remove(jointLocalToWorldChangedHandler);
		}

		override protected function sceneEnterFrameHandler(scene		: Scene,
														   viewport		: Viewport,
														   destination	: BitmapData,
														   time			: Number) : void
		{
			if (_isDirty)
			{
				_skinningHelper.update(_skeletonRoot, _joints);
				_isDirty = false;
			}
		}

		override public function clone() : AbstractController
		{
			return new SkinningController(_method, _skeletonRoot, _joints, bindShape, invBindMatrices);
		}
	}
}

package aerys.minko.scene.controller.mesh.skinning
{
	import aerys.minko.ns.minko_math;
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.controller.IRebindableController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Mesh;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.animation.SkinningMethod;
	import aerys.minko.type.binding.DataBindings;
	import aerys.minko.type.math.Matrix4x4;

	import flash.display.BitmapData;
	import flash.geom.Matrix3D;
	import flash.utils.Dictionary;

	public final class SkinningController extends EnterFrameController implements IRebindableController
	{
		private var _skinningHelper		: AbstractSkinningHelper;
		private var _isDirty			: Boolean;

		private var _method				: uint;
		private var _bindShapeMatrix	: Matrix3D;
		private var _skeletonRoot		: Group;
		private var _joints				: Vector.<Group>;
		private var _invBindMatrices	: Vector.<Matrix3D>;

		private var _numVisibleTargets	: uint;

		public function get skinningMethod() : uint
		{
			return _method;
		}

		public function get bindShape() : Matrix4x4
		{
			var bindShape : Matrix4x4 = new Matrix4x4();
			bindShape.minko_math::_matrix = _bindShapeMatrix;

			return bindShape;
		}

		public function get skeletonRoot() : Group
		{
			return _skeletonRoot;
		}

		public function get joints() : Vector.<Group>
		{
			return _joints;
		}

		public function get invBindMatrices() : Vector.<Matrix4x4>
		{
			var numMatrices		: uint					= _invBindMatrices.length;
			var invBindMatrices : Vector.<Matrix4x4>	= new Vector.<Matrix4x4>(numMatrices);

			for (var matrixId : uint = 0; matrixId < numMatrices; ++matrixId)
			{
				invBindMatrices[matrixId] = new Matrix4x4();
				invBindMatrices[matrixId].minko_math::_matrix = _invBindMatrices[matrixId];
			}

			return invBindMatrices;
		}

		public function SkinningController(method			: uint,
										   skeletonRoot		: Group,
										   joints			: Vector.<Group>,
										   bindShape		: Matrix4x4,
										   invBindMatrices	: Vector.<Matrix4x4>)
		{
			super(Mesh);

			_method				= method;
			_skeletonRoot		= skeletonRoot;
			_bindShapeMatrix	= bindShape.minko_math::_matrix;
			_isDirty			= false;

			initialize(joints, invBindMatrices);
		}

		private function initialize(joints			: Vector.<Group>,
									invBindMatrices	: Vector.<Matrix4x4>) : void
		{
			var numJoints : uint = joints.length;

			_joints	= joints.slice();

			_invBindMatrices	= new Vector.<Matrix3D>(numJoints, true);
			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_invBindMatrices[jointId] = invBindMatrices[jointId].minko_math::_matrix;

			if (skinningMethod == SkinningMethod.SOFTWARE_MATRIX)
				_skinningHelper = new SoftwareSkinningHelper(_method, _bindShapeMatrix, _invBindMatrices);
			else
				_skinningHelper = new ShaderSkinningHelper(_method, _bindShapeMatrix, _invBindMatrices);
		}

		override protected function targetAddedToSceneHandler(target	: ISceneNode,
															  scene		: Scene) : void
		{
			super.targetAddedToSceneHandler(target, scene);

			if (numTargetsInScene == 1)
				subscribeToJoints();

			var mesh : Mesh = target as Mesh;

			mesh.bindings.addCallback('inFrustum', meshVisibilityChangedHandler);
			_skinningHelper.addMesh(mesh);

			_isDirty = true;
		}

		override protected function targetRemovedFromSceneHandler(target	: ISceneNode,
																  scene		: Scene) : void
		{
			super.targetRemovedFromSceneHandler(target, scene);

			if (numTargets == 0)
				unsubscribeFromJoints();

			var mesh : Mesh = target as Mesh;

			mesh.bindings.removeCallback('inFrustum', meshVisibilityChangedHandler);
			_skinningHelper.removeMesh(mesh);
		}

		private function jointLocalToWorldChangedHandler(emitter : Matrix4x4) : void
		{
			_isDirty = true;
		}

		public function rebindDependencies(nodeMap			: Dictionary,
										   controllerMap	: Dictionary) : void
		{
			var numJoints	: uint = _joints.length;

			if (numTargets != 0)
				unsubscribeFromJoints();

			if (_joints.indexOf(_skeletonRoot) == -1 && nodeMap[_skeletonRoot])
				_skeletonRoot = nodeMap[_skeletonRoot];

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				if (nodeMap[_joints[jointId]])
					_joints[jointId] = nodeMap[_joints[jointId]];

			if (numTargets != 0)
				subscribeToJoints();

			_isDirty = true;
		}

		private function subscribeToJoints() : void
		{
			var numJoints	: uint = _joints.length;

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_joints[jointId].localToWorld.changed.add(jointLocalToWorldChangedHandler);

			if (_joints.indexOf(_skeletonRoot) == -1)
				_skeletonRoot.localToWorld.changed.add(jointLocalToWorldChangedHandler);
		}

		private function unsubscribeFromJoints() : void
		{
			var numJoints	: uint = _joints.length;

			for (var jointId : uint = 0; jointId < numJoints; ++jointId)
				_joints[jointId].localToWorld.changed.remove(jointLocalToWorldChangedHandler);

			if (_joints.indexOf(_skeletonRoot) == -1)
				_skeletonRoot.localToWorld.changed.remove(jointLocalToWorldChangedHandler);
		}

		override protected function sceneEnterFrameHandler(scene		: Scene,
														   viewport		: Viewport,
														   destination	: BitmapData,
														   time			: Number) : void
		{
			if (_isDirty && _skinningHelper.numMeshes != 0)
			{
				_skinningHelper.update(_skeletonRoot, _joints);
				_isDirty = false;
			}
		}

		override public function clone() : AbstractController
		{
			return new SkinningController(_method, _skeletonRoot, _joints, bindShape, invBindMatrices);
		}

		private function meshVisibilityChangedHandler(bindings 	: DataBindings,
												  property	: String,
												  oldValue	: Boolean,
												  newValue	: Boolean) : void
		{
			if (newValue)
				_skinningHelper.addMesh(bindings.owner as Mesh);
			else
				_skinningHelper.removeMesh(bindings.owner as Mesh);
		}
	}
}

update SkinningController to avoid any computation when there is no target in the scene/frustum