toString can now be used as a variable name

Change-Id: I24c29bc05ac4585574c3856f7a1b312656d33440

--- WeaveCore/src/weave/compiler/Compiler.as
+++ WeaveCore/src/weave/compiler/Compiler.as
@@ -1866,7 +1866,7 @@
 				return statements.hasOwnProperty(token);

 			var method:* = call.evaluatedMethod;
-			return (JUMP_LOOKUP[method] || LOOP_LOOKUP[method])
+			return (JUMP_LOOKUP[method as Function] || LOOP_LOOKUP[method as Function])
 		}

 		/**
@@ -1995,7 +1995,7 @@
 				return params[INDEX_CONDITION];
 			}

-			if (PURE_OP_LOOKUP[method])
+			if (PURE_OP_LOOKUP[method as Function])
 			{
 				// if all parameters are constants, just evaluate the pure operator as a constant.
 				for each (var param:Object in params)
@@ -2055,7 +2055,7 @@
 			if (cMethod && constants[cMethod.name] == cMethod.value && operators[op] == cMethod.value)
 			{
 				var n:int = cParams.length;
-				if (n > 0 && (ASSIGN_OP_LOOKUP[cMethod.value] || op == '.' || op == '..'))
+				if (n > 0 && (ASSIGN_OP_LOOKUP[cMethod.value as Function] || op == '.' || op == '..'))
 				{
 					var result:String = params[0];
 					for (i = 1; i < n; i++)
@@ -2104,7 +2104,7 @@
 				if (op == '(' && n > 0) // zero params not allowed for this syntax
 					return '(' + params.join('; ') + ')';

-				if (PURE_OP_LOOKUP[cMethod.value] || op == 'in')
+				if (PURE_OP_LOOKUP[cMethod.value as Function] || op == 'in')
 				{
 					if (n == 1) // unary op
 					{
@@ -2245,7 +2245,7 @@

 					if (compiledParams)
 					{
-						if (LOOP_LOOKUP[method] && call.evalIndex == INDEX_METHOD)
+						if (LOOP_LOOKUP[method as Function] && call.evalIndex == INDEX_METHOD)
 						{
 							if (method == operators[ST_DO] || method == operators[ST_FOR_DO])
 							{
@@ -2262,7 +2262,7 @@

 							// handle branching and short-circuiting
 							// skip evaluation of true or false branch depending on condition and branch operator
-							if (BRANCH_LOOKUP[method] !== undefined && call.evalIndex > INDEX_CONDITION)
+							if (BRANCH_LOOKUP[method as Function] !== undefined && call.evalIndex > INDEX_CONDITION)
 								if (BRANCH_LOOKUP[method] == (call.evalIndex != (call.evaluatedParams[INDEX_CONDITION] ? INDEX_TRUE : INDEX_FALSE)))
 									continue;

@@ -2275,7 +2275,7 @@
 							{
 								// special case for for-in and for-each
 								// implemented as "for (each|in)(\in(list), item=undefined, stmt)
-								if (LOOP_LOOKUP[method] && call.evalIndex == INDEX_FOR_ITEM && (method == operators[ST_FOR_IN] || method == operators[ST_FOR_EACH]))
+								if (LOOP_LOOKUP[method as Function] && call.evalIndex == INDEX_FOR_ITEM && (method == operators[ST_FOR_IN] || method == operators[ST_FOR_EACH]))
 								{
 									if ((call.evaluatedParams[INDEX_FOR_LIST] as Array).length > 0)
 									{
@@ -2334,7 +2334,7 @@
 							if (i == allSymbolTables.length)
 								result = getDefinitionByName(symbolName);
 						}
-						else if (JUMP_LOOKUP[method])
+						else if (JUMP_LOOKUP[method as Function])
 						{
 							if (method == operators[ST_RETURN])
 							{
@@ -2350,7 +2350,7 @@

 									call = stack[stack.length - 1] as CompiledFunctionCall;
 									method = call.evaluatedMethod;
-									if (LOOP_LOOKUP[method] && LOOP_LOOKUP[method] != ST_BREAK)
+									if (LOOP_LOOKUP[method as Function] && LOOP_LOOKUP[method as Function] != ST_BREAK)
 										break; // loop will be handled below.
 								}
 							}
@@ -2360,7 +2360,7 @@
 								{
 									call = stack.pop() as CompiledFunctionCall;
 									method = call.evaluatedMethod;
-									if (LOOP_LOOKUP[method] && LOOP_LOOKUP[method] != ST_CONTINUE)
+									if (LOOP_LOOKUP[method as Function] && LOOP_LOOKUP[method as Function] != ST_CONTINUE)
 									{
 										method = operators[ST_BREAK];
 										continue stackLoop;
@@ -2374,7 +2374,7 @@
 								throw call.evaluatedParams[0];
 							}
 						}
-						else if (ASSIGN_OP_LOOKUP[method] && compiledParams.length == 2) // two params means local assignment
+						else if (ASSIGN_OP_LOOKUP[method as Function] && compiledParams.length == 2) // two params means local assignment
 						{
 							// local assignment
 							symbolName = call.evaluatedParams[0];
@@ -2499,7 +2499,7 @@
 					}

 					// handle while and for loops
-					if (LOOP_LOOKUP[method])
+					if (LOOP_LOOKUP[method as Function])
 					{
 						if (method == operators[ST_FOR_IN] || method == operators[ST_FOR_EACH])
 						{


added test case.

added test case.

--- WeaveCore/src/weave/compiler/Compiler.as
+++ WeaveCore/src/weave/compiler/Compiler.as
@@ -2455,7 +2455,8 @@
 				"i = -1; while (++i < 10) { if (i == 3) continue; trace(i); if (i == 5) break; } trace('done');",
 				"a = []; o = Object('a',1,'b',2,'c',3,'d',4,'e',5); for (k in o) { a.push(`{k} = {o[k]}`); o['?'+k]=k+'!'; delete o[k]; } for each (p in o) a.push(p); return [a,o];",
 				"y = 4; x = 3; var x = 4, y; [x, y]",
-				"`abc { function(x,y) { return x+y; } } xyz`"
+				"`abc { function(x,y) { return x+y; } } xyz`",
+				"var obj = Object('f', function() { return this == obj; }); var ff = obj.f; [obj.f(), (obj.f)(), ff()]"
 			];
 			var values:Array = [-2, -1, -0.5, 0, 0.5, 1, 2];
 			var vars:Object = {};


object casting now converts unclassed Objects to classed instances.

--- WeaveCore/src/weave/compiler/Compiler.as
+++ WeaveCore/src/weave/compiler/Compiler.as
@@ -2526,7 +2526,7 @@
 							}
 							else // all other single-parameter type casting operations
 							{
-								result = method(call.evaluatedParams[0]);
+								result = cast(call.evaluatedParams[0], method as Class);
 							}
 						}
 						else if (method == operators[ST_VAR]) // variable initialization
@@ -2644,6 +2644,25 @@
 		public function compiledObjectIsFunctionDefinition(compiledObject:ICompiledObject):Boolean
 		{
 			return compiledObject is CompiledFunctionCall && (compiledObject as CompiledFunctionCall).evaluatedMethod == operators[FUNCTION];
+		}
+
+		/**
+		 * Casts an object to a specified type.
+		 * If given an unclassed Object, the properties will be copied over to a new instance of the type.
+		 * @param object An object to cast.
+		 * @param type The desired type.
+		 * @return An instance of the desired type.
+		 * @throws Error If unable to cast the object to the desired type.
+		 */
+		public static function cast(object:Object, type:Class):*
+		{
+			if (object is type || object === null || object.constructor != Object)
+				return type(object);
+			var newObj:Object = new type();
+			for (var key:String in object)
+				if (newObj.hasOwnProperty(key))
+					newObj[key] = object[key];
+			return newObj;
 		}

 		public static const _do_continue_test:String = <![CDATA[


Transferred from the Adobe Open Source Subversion Repository

Revision: 12850
Author:   jimurphy@adobe.com
Date:     2009-12-11T14:57:14.623098Z

Log Message:
-----------
add 6 new DMV projects to the SDK:
automation
automation_air
automation_dmv
automation_flashflexkit
automation_spark
datavisualization

These projects are setup to build in an ant main call.  There are currently several warnings in the datavisualization project that will be cleaned up.  No checkintests exist for these projects as of yet.

I also modified the exisitng projects build files for easier management of the localization targets, bundle and fat-swc. If the projects that I updated:airframework,airspark,framework,playerglobal,rpc,and spark.  All the new projects have been implemented this same way.

QE notes: DMV folks should run through their tests
Doc notes: probably
Bugs: nope
Reviewer:
Tests run: ran the following targets: compile,checkintests,other.locales and doc
Is noteworthy for integration: no

Modified Paths:
--------------
1404 paths were modified

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

--- frameworks/projects/advancedgrids/src/mx/olap/aggregators/CountAggregator.as
+++ frameworks/projects/advancedgrids/src/mx/olap/aggregators/CountAggregator.as
@@ -0,0 +1,139 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2009 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.olap.aggregators
+{
+import mx.olap.IOLAPCustomAggregator;
+
+/**
+ *  The CountAggregator class  implements the count aggregator.
+ *  The count aggregator returns the count of the measures.
+ *  Flex uses this aggregator when you set the OLAPMeasure.aggregator property
+ *  to "COUNT".
+ *
+ *  @see mx.olap.OLAPMeasure
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class CountAggregator implements IOLAPCustomAggregator
+{
+	//--------------------------------------------------------------------------
+    //
+    // Methods
+    //
+    //--------------------------------------------------------------------------
+
+	//count functions.
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeBegin(dataField:String):Object
+	{
+		var newObj:Object = {};
+		newObj[dataField] = [];
+		newObj[dataField + "Counter"] = 0;
+		return newObj;
+	}
+
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeLoop(data:Object, dataField:String, value:Object):void
+	{
+		if (!data.hasOwnProperty(dataField))
+		{
+			data[dataField] = [value[dataField]];
+			data[dataField + "Counter"] = 1;
+		}
+		else
+		{
+			data[dataField].push(value[dataField]);
+			data[dataField + "Counter"] = data[dataField + "Counter"] + 1;
+		}
+	}
+
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeEnd(data:Object, dataField:String):Number
+	{
+		return data[dataField + "Counter"];
+	}
+
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeObjectBegin(value:Object):Object
+	{
+		var newObj:Object = {};
+		for (var p:String in value)
+		{
+			newObj[p] = value[p];
+		}
+		return newObj;
+	}
+
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeObjectLoop(oldValue:Object, newValue:Object):void
+	{
+		for (var p:String in newValue)
+		{
+			if (oldValue[p] is Array)
+				oldValue[p] = oldValue[p].concat(newValue[p]);
+			else
+			oldValue[p] += newValue[p];
+	    }
+	}
+
+    /**
+     *  @inheritDoc
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function computeObjectEnd(oldValue:Object, dataField:String):Number
+	{
+		return oldValue[dataField + "Counter"];
+	}
+}
+}


FLEX-33666: Mouse wheel events will now end the item edit.  It will default to saving the edited text.

--- frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as
+++ frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as
@@ -450,7 +450,7 @@
     {
         // add listeners to enable cell editing
         var grid:Grid = dataGrid.grid;
-
+
         dataGrid.addEventListener(KeyboardEvent.KEY_DOWN, dataGrid_keyboardDownHandler);

         // Make sure we get first shot at mouse events before selection is changed. We use
@@ -458,6 +458,7 @@
         grid.addEventListener(GridEvent.GRID_MOUSE_DOWN, grid_gridMouseDownHandler, false, 1000);
         grid.addEventListener(GridEvent.GRID_MOUSE_UP, grid_gridMouseUpHandler, false, 1000);
         grid.addEventListener(GridEvent.GRID_DOUBLE_CLICK, grid_gridDoubleClickHandler);
+        grid.addEventListener(MouseEvent.MOUSE_WHEEL, grid_gridMouseWheelHandler, false, 0);
     }

     /**
@@ -468,11 +469,11 @@
     public function uninitialize():void
     {
         // remove listeners to disable cell editing
-
         grid.removeEventListener(KeyboardEvent.KEY_DOWN, dataGrid_keyboardDownHandler);
         grid.removeEventListener(GridEvent.GRID_MOUSE_DOWN, grid_gridMouseDownHandler);
         grid.removeEventListener(GridEvent.GRID_MOUSE_UP, grid_gridMouseUpHandler);
         grid.removeEventListener(GridEvent.GRID_DOUBLE_CLICK, grid_gridDoubleClickHandler);
+        grid.removeEventListener(MouseEvent.MOUSE_WHEEL, grid_gridMouseWheelHandler);
     }

     /**
@@ -1465,6 +1466,17 @@
         lastItemDown = null;
     }

+
+    /**
+    *  @private
+    *
+    */
+    protected function grid_gridMouseWheelHandler(event:MouseEvent):void
+    {
+        endEdit();
+    }
+
+
     /**
      *  @private
      *


Transferred from the Adobe Open Source Subversion Repository

Revision: 18006
Author:   dloverin@adobe.com
Date:     2010-10-04T21:04:40.944454Z

Log Message:
-----------
DataGrid editor api changes, clean up, and bug fixes.

QE notes: Not ready for testing.
Doc notes: None.
Bugs:
Reviewer: Hans
Tests run: checkintests
Is noteworthy for integration: No.

Modified Paths:
--------------
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/IGridItemEditor.as</path>
<path kind="file" copyfrom-path="/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/DataGridEditor.as" copyfrom-rev="17973" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/gridClasses/TextGridItemEditor.mxml</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/GridColumn.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/gridClasses/GridItemEditor.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/DataGrid.as</path>
<path kind="file" action="D">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/supportClasses/DataGridEditor.as</path>
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/spark/src/spark/components/gridClasses/ComboBoxGridItemEditor.mxml</path>

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

--- frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as
+++ frameworks/projects/spark/src/spark/components/gridClasses/DataGridEditor.as
@@ -9,7 +9,15 @@
 //
 ////////////////////////////////////////////////////////////////////////////////

-package spark.components.supportClasses
+/**
+ *  The DataGridEditor contains all the logic and event handling needed to
+ *  manage the life cycle of an item editor. A DataGridEditor is owned by a
+ *  specified DataGrid. The owning DataGrid is responsible for calling
+ *  initialize() to enable editing and uninitialize() when editing is no
+ *  longer needed.
+ *
+ */
+package spark.components.gridClasses
 {
 import flash.display.DisplayObjectContainer;
 import flash.display.DisplayObject;
@@ -38,6 +46,8 @@
 import mx.managers.IFocusManager;
 import mx.managers.IFocusManagerComponent;

+import spark.components.supportClasses.CellPosition;
+import spark.components.supportClasses.GridColumn;
 import spark.components.IGridItemEditor;
 import spark.components.DataGrid;
 import spark.components.Grid;
@@ -76,10 +86,46 @@
     //  Variables
     //
     //--------------------------------------------------------------------------
+    /**
+     *  @private
+     *  The state of the grid selection at the last selection snapshot. Used in
+     *  row selection mode.
+     */
     private var previouslySelectedIndices:Vector.<int>;
+
+    /**
+     *  @private
+     *  The state of the grid selection at the last selection snapshot. Used in
+     *  cell selection mode.
+     *
+     */
     private var previouslySelectedCells:Vector.<CellPosition>;

+    /**
+     *  @private
+     */
     private var lastEvent:Event;
+
+
+    /**
+     *  @private
+     *  Used to restore the value of DataGrid's hasFocusableChildren.
+     */
+    private var saveDataGridHasFocusableChildren:Boolean;
+
+    /**
+     *  @private
+     *  Used to restore the value of scroller's hasFocusableChildren.
+     */
+    private var saveScrollerHasFocusableChildren:Boolean;
+
+    /**
+     *  @private
+     *  true if a new editor is planned to be started
+     *  after the current editor is closed. This hint can keep us from doing
+     *  work when closing the editor that would just need to be redone shortly.
+     */
+    private var willStartNewEditor:Boolean;

     //--------------------------------------------------------------------------
     //
@@ -87,20 +133,29 @@
     //
     //--------------------------------------------------------------------------

+    /**
+     *  @private
+     */
     private var _dataGrid:DataGrid;

+    /**
+     *  @private
+     *  The data grid that owns this editor.
+     */
     public function get dataGrid():DataGrid
     {
         return _dataGrid;
     }

+    /**
+     *  @private
+     *  Convenience property to get the grid.
+     */
     public function get grid():Grid
     {
         return _dataGrid.grid;
     }

-    // properties that control how the cell editor behaves. This can be based on item editor properties.
-
     //----------------------------------
     //  editedItemPosition
     //----------------------------------
@@ -120,6 +175,9 @@

     /**
      *  @private
+     *
+     *  Used to make sure the mouse up is on the same item
+     *  renderer as the mouse down.
      */
     private var lastItemDown:IVisualElement;

@@ -147,8 +205,6 @@
      */
     private var itemEditorPositionChanged:Boolean = false;

-
-    [Bindable("itemFocusIn")]

     /**
      *  The column and row index of the item renderer for the
@@ -208,50 +264,6 @@
         commitEditedItemPosition(coord);
     }

-// TODO (dloverin): investigate why imeMode is needed and how it is used
-//    //----------------------------------
-//    //  imeMode
-//    //----------------------------------
-//
-//    /**
-//     *  @private
-//     */
-//    private var _imeMode:String = null;
-//
-//    [Inspectable(environment="none")]
-//
-//    /**
-//     *  Specifies the IME (input method editor) mode.
-//     *  The IME enables users to enter text in Chinese, Japanese, and Korean.
-//     *  Flex sets the specified IME mode when the control gets the focus,
-//     *  and sets it back to the previous value when the control loses the focus.
-//     *
-//     *
The flash.system.IMEConversionMode class defines constants for the
-//     *  valid values for this property.
-//     *  You can also specify null to specify no IME.

-//     *
-//     *  @see flash.system.IMEConversionMode
-//     *
-//     *  @default null
-//     *
-//     *  @langversion 3.0
-//     *  @playerversion Flash 9
-//     *  @playerversion AIR 1.1
-//     *  @productversion Flex 3
-//     */
-//    public function get imeMode():String
-//    {
-//        return _imeMode;
-//    }
-//
-//    /**
-//     *  @private
-//     */
-//    public function set imeMode(value:String):void
-//    {
-//        _imeMode = value;
-//    }
-//
     /**
      *  @private
      *  true if we want to block editing on mouseUp
@@ -321,6 +333,52 @@
         return _editedItemRenderer;
     }

+    //----------------------------------
+    //  editorColumnIndex
+    //----------------------------------
+
+    /**
+     *  The zero-based column index of the cell that is being edited. The
+     *  value is -1 if no cell is being edited.
+     *
+     *  @default -1
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 4.5
+     */
+    public function get editorColumnIndex():int
+    {
+        if (editedItemPosition)
+            return editedItemPosition.columnIndex;
+
+        return -1;
+    }
+
+    //----------------------------------
+    //  editorRowIndex
+    //----------------------------------
+
+    /**
+     *  The zero-based row index of the cell that is being edited. The
+     *  value is -1 if no cell is being edited.
+     *
+     *  @default -1
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 4.5
+     */
+    public function get editorRowIndex():int
+    {
+        if (editedItemPosition)
+            return editedItemPosition.rowIndex;
+
+        return -1;
+    }
+
     //--------------------------------------------------------------------------
     //
     //  Methods
@@ -344,10 +402,6 @@
         grid.addEventListener(MouseEvent.MOUSE_DOWN, grid_mouseDownHandler, false, 1000);
         grid.addEventListener(GridEvent.GRID_MOUSE_DOWN, grid_gridMouseDownHandler);
         grid.addEventListener(GridEvent.GRID_MOUSE_UP, grid_gridMouseUpHandler);
-
-        dataGrid.addEventListener(DataGridEditEvent.START_GRID_ITEM_EDITOR_SESSION,
-            dataGrid_startItemEditorSessionHandler,
-            false, EventPriority.DEFAULT_HANDLER);
     }

     /**
@@ -407,21 +461,6 @@
             if (grid.focusManager)
                 grid.focusManager.defaultButtonEnabled = true;

-//                var event:DataGridEvent =
-//                    new DataGridEvent(DataGridEvent.ITEM_FOCUS_OUT);
-//                event.columnIndex = _editedItemPosition.columnIndex;
-//                event.rowIndex = _editedItemPosition.rowIndex;
-//                //event.itemRenderer = itemEditorInstance;
-//                dataGrid.dispatchEvent(event);
-
-                //            if (! columns.getItemAt(_editedItemPosition.columnIndex).rendererIsEditor)
-                //            {
-                // FocusManager.removeHandler() does not find
-                // itemEditors in focusableObjects[] array
-                // and hence does not remove the focusRectangle
-//                 if (itemEditorInstance && itemEditorInstance is UIComponent)
-//                    UIComponent(itemEditorInstance).drawFocus(false);
-//
             // setfocus back to us so something on stage has focus
             deferFocus();

@@ -430,10 +469,9 @@
             if (itemEditorInstance)
                 dataGrid.itemEditorLayer.removeElement(itemEditorInstance);

-            dataGrid.hasFocusableChildren = false; // TODO (dloverin): restore to last value not always false
+            dataGrid.hasFocusableChildren = saveDataGridHasFocusableChildren;
             if (dataGrid.grid)
-                dataGrid.grid.hasFocusableChildren = false; // TODO (dloverin): restore to last value not always false
-
+                dataGrid.grid.hasFocusableChildren = saveDataGridHasFocusableChildren;

             itemEditorInstance = null;
             _editedItemRenderer = null;
@@ -488,13 +526,8 @@

         _editedItemRenderer = item;

-        if (!col.renderIsEditable)
-        {
-            var dx:Number = 0;
-            var dy:Number = 0; // TODO: (dloverin) why was this -2;
-            var dw:Number = 0;
-            var dh:Number = 0 // TODO: (dloverin) whay was this 4;
-
+        if (!col.rendererIsEditable)
+        {
             // if this isn't implemented, use an input control as editor
             if (!itemEditorInstance)
             {
@@ -531,12 +564,6 @@
                 //                    }
                 //                }

-                //                // TODO: (dloverin) do we need this properties?
-                //                dx = col.editorXOffset;
-                //                dy = col.editorYOffset;
-                //                dw = col.editorWidthOffset;
-                //                dh = col.editorHeightOffset;
-
                 itemEditorInstance = itemEditor.newInstance();
                 itemEditorInstance.owner = dataGrid;
                 itemEditorInstance.data = IGridItemRenderer(item).data;
@@ -550,6 +577,10 @@
                 if (dataGrid.itemEditorLayer)
                 {
                     dataGrid.itemEditorLayer.addElement(itemEditorInstance);
+
+                    // Need to turn on focusable children flag so focus manager will
+                    // allow focus into the data grid's children.
+                    saveDataGridHasFocusableChildren = dataGrid.hasFocusableChildren;
                     dataGrid.hasFocusableChildren = true;
                 }
             }
@@ -558,17 +589,17 @@
             if (itemEditorInstance is IInvalidating)
                 IInvalidating(itemEditorInstance).validateNow();

-            // TODO (dloverin): Should IGridItemEditor implement IUIComponent? Why isn't IVisualElement enough?
+            itemEditorInstance.setLayoutBoundsSize(
+                Math.min(item.width,
+                    grid.width - 1 - itemEditorInstance.x),
+                Math.min(item.height,
+                    grid.height - itemEditorInstance.y));
+            itemEditorInstance.setLayoutBoundsPosition(cellBounds.x, cellBounds.y);
+
+            // TODO (dloverin): set max width/height not to exceed the width
+            // of the application. Set min width/height using spark layout api.
             if (itemEditorInstance is IUIComponent)
             {
-                // position and set the size of the editor.
-                IUIComponent(itemEditorInstance).move(cellBounds.x + dx, cellBounds.y + dy);
-                IUIComponent(itemEditorInstance).setActualSize(
-                    Math.min(item.width + dw,
-                        grid.width - 1 - itemEditorInstance.x),
-                    Math.min(item.height + dh,
-                        grid.height - itemEditorInstance.y));
-
                 // set the min width and height of the editor to the cell bounds.
                 // set the max widht and height of the editor not to exceed the
                 // bounds of the application.
@@ -577,12 +608,9 @@
                     UIComponent(itemEditorInstance).minWidth = cellBounds.width;
                     UIComponent(itemEditorInstance).minHeight = cellBounds.height;

-                    // TODO (dloverin): set max width/height not to exceed the width
-                    // of the application.
                 }
-
-
             }
+
             itemEditorInstance.prepare();
             DisplayObject(dataGrid.itemEditorLayer).visible = true;
             itemEditorInstance.visible = true;
@@ -603,9 +631,16 @@
             {
                 var fm:FocusManager = grid.focusManager as FocusManager;

+                // Need to turn on focusable children flag so focus manager will
+                // allow focus into the data grid's children.
+                saveDataGridHasFocusableChildren = dataGrid.hasFocusableChildren;
                 dataGrid.hasFocusableChildren = true;
+
                 if (dataGrid.scroller)
+                {
+                    saveScrollerHasFocusableChildren = dataGrid.scroller.hasFocusableChildren;
                     dataGrid.scroller.hasFocusableChildren = true;
+                }

                 var o:DisplayObject = item as DisplayObject;
                 var found:Boolean = false;
@@ -670,13 +705,6 @@
         // we disappear if stage or our grid is resized
         grid.systemManager.addEventListener(Event.RESIZE, editorAncestorResizeHandler);
         grid.addEventListener(Event.RESIZE, editorAncestorResizeHandler);
-
-        // Dispatch our item editor created event
-        // TODO (dloverin): should we create an equivalent event?
-
-//            var event:DataGridEvent =
-//                new DataGridEvent(DataGridEvent.ITEM_EDITOR_CREATE, false, true, colIndex, null, rowIndex);
-//            dataGrid.dispatchEvent(event);
     }

     /**
@@ -694,23 +722,26 @@
     public function startItemEditorSession(rowIndex:int, columnIndex:int):Boolean
     {

+        dataGrid.addEventListener(DataGridEditEvent.START_GRID_ITEM_EDITOR_SESSION,
+                                  dataGrid_startItemEditorSessionHandler,
+                                  false, EventPriority.DEFAULT_HANDLER);
+
         var dataGridEvent:DataGridEditEvent =
             new DataGridEditEvent(DataGridEditEvent.START_GRID_ITEM_EDITOR_SESSION, false, true);

-        // The BEGIN_GRID_ITEM_EDITOR_CREATION event is cancelable
+        // The START_GRID_ITEM_EDITOR_SESSION event is cancelable
         dataGridEvent.rowIndex = Math.min(rowIndex, grid.dataProvider.length - 1);
         dataGridEvent.columnIndex = Math.min(columnIndex, grid.columns.length - 1);
         dataGridEvent.column = grid.columns.getItemAt(columnIndex) as GridColumn;

-        //dataGridEvent.dataField = grid.columns.getItemAt(columnIndex).dataField;
-        //dataGridEvent.itemRenderer = itemRenderer;
-        if (!dataGrid.dispatchEvent(dataGridEvent))
-        {
+        var editorStarted:Boolean = !dataGrid.dispatchEvent(dataGridEvent);
+        if (editorStarted)
             lastEditedItemPosition = { columnIndex: columnIndex, rowIndex: rowIndex };
-            return true;
-        }
-
-        return false;
+
+        dataGrid.removeEventListener(DataGridEditEvent.START_GRID_ITEM_EDITOR_SESSION,
+                                     dataGrid_startItemEditorSessionHandler);
+
+        return editorStarted;
     }

     /**
@@ -730,7 +761,7 @@
         }
         else
         {
-            return endEdit("");
+            return endEdit();
         }
     }

@@ -743,35 +774,45 @@
     {
         if (itemEditorInstance)
         {
-            // Notify event that the editor session is cancelled.
-            // This event cannot be cancelled.
-            var dataGridEvent:DataGridEditEvent =
-                new DataGridEditEvent(DataGridEditEvent.CANCEL_GRID_ITEM_EDITOR_SESSION);
-
-            dataGridEvent.columnIndex = editedItemPosition.columnIndex;
-            dataGridEvent.column = itemEditorInstance.column;
-            dataGridEvent.rowIndex = editedItemPosition.rowIndex;
-            dataGrid.dispatchEvent(dataGridEvent);
-
+            // send the cancel event and tear down the editor.
+            dispatchCancelEvent();
             destroyItemEditor();
         }
         else if (editedItemRenderer)
         {
+            // cancel focus in an item editor by setting focus back to the grid.
             dataGrid.setFocus();
         }

     }
-
-    /**
-     *  @private
+
+
+    /**
+     *  @private
+     *
+     *  Notify event that the editor session is cancelled.
+     *  This event cannot be cancelled.
+     */
+    private function dispatchCancelEvent():void
+    {
+        var dataGridEvent:DataGridEditEvent =
+            new DataGridEditEvent(DataGridEditEvent.CANCEL_GRID_ITEM_EDITOR_SESSION);
+
+        dataGridEvent.columnIndex = editedItemPosition.columnIndex;
+        dataGridEvent.column = itemEditorInstance.column;
+        dataGridEvent.rowIndex = editedItemPosition.rowIndex;
+        dataGrid.dispatchEvent(dataGridEvent);
+    }
+
+    /**
+     *  @private
+     *
      *  When the user finished editing an item, this method is called.
-     *
      *
      */
-    // TODO (dloverin): remove reason from this function
-
-    private function endEdit(reason:String):Boolean
-    {
+    private function endEdit():Boolean
+    {
+        // Focus is inside an item renderer
         if (!itemEditorInstance && editedItemRenderer)
         {
             inEndEdit = true;
@@ -789,7 +830,8 @@
         var itemPosition:Object = editedItemPosition;
         if (!saveItemEditorSession())
         {
-            // TODO (dloverin): need to dispatch a cancel event in this case
+            // the save was cancelled so dispatch a cancel event.
+            dispatchCancelEvent();
             inEndEdit = false;
             return false;
         }
@@ -833,18 +875,7 @@
         // dispose of any existing editor, saving away its data first
         if (itemEditorInstance)
         {
-            var reason:String;
-            if (!coord)
-            {
-                reason = "DataGridEventReason.OTHER";
-            }
-            else
-            {
-                reason = (!editedItemPosition || coord.rowIndex == editedItemPosition.rowIndex) ?
-                    "DataGridEventReason.NEW_COLUMN" :
-                    "DataGridEventReason.NEW_ROW";
-            }
-            if (!endEdit(reason) && reason != "DataGridEventReason.OTHER")
+            if (!endEdit())
                 return;
         }

@@ -862,29 +893,6 @@

         var rowIndex:int = coord.rowIndex;
         var columnIndex:int = coord.columnIndex;
-        //        if (displayableColumns.length != _columns.length)
-        //        {
-        //            for (var i:int = 0; i < displayableColumns.length; i++)
-        //            {
-        //                if (displayableColumns[i].colNum >= columnIndex)
-        //                {
-        //                    columnIndex = i;
-        //                    break;
-        //                }
-        //            }
-        //            if (i == displayableColumns.length)
-        //                columnIndex = 0;
-        //        }
-
-        // trace("commitEditedItemPosition ", coord.rowIndex, selectedIndex);
-
-        //        var needChangeEvent:Boolean = false;
-        //        if (selectedIndex != coord.rowIndex)
-        //        {
-        //            commitSelectedIndex(coord.rowIndex);
-        //            needChangeEvent = true;
-        //        }
-        //

         dataGrid.ensureCellIsVisible(rowIndex, columnIndex);

@@ -922,10 +930,11 @@

         if (itemEditorInstance is IInvalidating)
             IInvalidating(itemEditorInstance).validateNow();
-
-        //            if (itemEditorInstance is IIMESupport)
-        //                IIMESupport(itemEditorInstance).imeMode =
-        //                    (columns.getItemAt(event.columnIndex).imeMode == null) ? _imeMode : columns[event.columnIndex].imeMode;
+
+        var column:GridColumn = dataGrid.columns.getItemAt(columnIndex) as GridColumn;
+        if (itemEditorInstance is IIMESupport)
+            IIMESupport(itemEditorInstance).imeMode =
+                (column.imeMode == null) ? dataGrid.imeMode : column.imeMode;

         var fm:IFocusManager = grid.focusManager;
         // trace("setting focus to item editor");
@@ -939,7 +948,7 @@
             new DataGridEditEvent(DataGridEditEvent.OPEN_GRID_ITEM_EDITOR_SESSION);

         dataGridEvent.columnIndex = editedItemPosition.columnIndex;
-        dataGridEvent.column = dataGrid.columns.getItemAt(columnIndex) as GridColumn;
+        dataGridEvent.column = column;
         dataGridEvent.rowIndex = editedItemPosition.rowIndex;
         dataGrid.dispatchEvent(dataGridEvent);
     }
@@ -1078,6 +1087,9 @@
      */
     private function dataGrid_keyboardDownHandler(event:KeyboardEvent):void
     {
+        if (!dataGrid.editable)
+            return;
+
         lastEvent = event;

         if (event.keyCode == dataGrid.editKey)
@@ -1111,6 +1123,9 @@
      */
     private function grid_mouseDownHandler(event:MouseEvent):void
     {
+        if (!dataGrid.editable)
+            return;
+
         lastEvent = event;

         if (dataGrid.isRowSelectionMode())
@@ -1122,6 +1137,10 @@
         {
             previouslySelectedIndices = null;
             previouslySelectedCells = dataGrid.selectedCells.slice(0, dataGrid.selectedCells.length);
+//            for each (var cell:CellPosition in dataGrid.selectedCells)
+//            {
+//                trace("cell position = (" + cell.rowIndex + "," + cell.columnIndex + ")");
+//            }
         }
     }

@@ -1131,17 +1150,18 @@
      */
     private function grid_gridMouseDownHandler(event:GridEvent):void
     {
+        if (!dataGrid.editable)
+            return;
+
         lastEvent = event;

-        const rowIndex:int = event.rowIndex; //gridDimensions.getRowIndexAt(eventGridXY.x, eventGridXY.y);
-        const columnIndex:int = event.columnIndex; //gridDimensions.getColumnIndexAt(eventGridXY.x, eventGridXY.y);
-
-//        trace("grid_gridMouseDownHandler: (rowIndex, columnIndex) = (" + rowIndex + "," + columnIndex + ")");
+        const rowIndex:int = event.rowIndex;
+        const columnIndex:int = event.columnIndex;
+
+        //trace("grid_gridMouseDownHandler: (rowIndex, columnIndex) = (" + rowIndex + "," + columnIndex + ")");

         // item editor handling
-        var r:IVisualElement;
-
-        r = event.itemRenderer; // grid.getItemRendererAt(rowIndex, columnIndex);
+        var r:IGridItemRenderer = event.itemRenderer as IGridItemRenderer;

         lastItemDown = null;

@@ -1150,56 +1170,18 @@
         if (event.shiftKey || event.ctrlKey)
             return;

-        //            var isItemEditor:Boolean = itemEditorInstance && grid.contains(DisplayObject(itemEditorInstance));
-        //
-        //            // If it isn't an item renderer, or an item editor do default behavior
-        //            if (!isItemEditor)
-        //            {
-       // trace("mouseDown rowIndex is selected = " + priorSelectedIndices.indexOf(rowIndex));
-
-        var pos:Point;
+        // if an editor is already up, close it without starting a new editor.
+        if (itemEditorInstance)
+        {
+            endEdit();
+            return;
+        }
+
         if (r && wasCellPreviouslySelected(rowIndex, columnIndex))
         {
+            //trace("cell was previously selected: (" + rowIndex + "," + columnIndex + ")");
             lastItemDown = r;
-
-            //                pos = itemRendererToIndices(r);
-
-            var bEndedEdit:Boolean = true;
-
-            if (itemEditorInstance)
-            {
-                if (grid.columns[columnIndex].editable == false)
-                {
-                    endEdit("DataGridEventReason.OTHER");
-                    bEndedEdit = true;
-                }
-                else
-                {
-                    //Possible to get here and not have an editedItemPosition
-                    if (editedItemPosition)
-                    {
-                        bEndedEdit = endEdit(editedItemPosition.rowIndex == pos.y ?
-                            "DataGridEventReason.NEW_COLUMN" :
-                            "DataGridEventReason.NEW_ROW");
-                    }
-                    else
-                    {
-                        bEndedEdit = false;
-                    }
-                }
-            }
-
-            // if we didn't end edit session, don't do default behavior (call super)
-            if (!bEndedEdit)
-                return;
-        }
-        else
-        {
-            // trace("end edit?");
-            if (itemEditorInstance)
-                endEdit("DataGridEventReason.OTHER");
-        }
-        //            }
+        }

     }

@@ -1210,9 +1192,9 @@
      */
     private function grid_gridMouseUpHandler(event:GridEvent):void
     {
-        //            const eventStageXY:Point = new Point(event.stageX, event.stageY);
-        //            const eventGridXY:Point = grid.globalToLocal(eventStageXY);
-        //            const gridDimensions:GridDimensions = GridLayout(grid.layout).gridDimensions;
+        if (!dataGrid.editable)
+            return;
+
         lastEvent = event;

         const eventRowIndex:int = event.rowIndex; //gridDimensions.getRowIndexAt(eventGridXY.x, eventGridXY.y);
@@ -1225,11 +1207,10 @@

         const rowIndex:int = eventRowIndex;
         var columnIndex:int = eventColumnIndex;
-        var pos:Point;

         var r:IVisualElement = event.itemRenderer; // grid.getItemRendererAt(rowIndex, eventColumnIndex);
         //trace("grid_gridMouseUpHandler: itemRenderer = " + event.itemRenderer);
-        if (r && r != itemEditorInstance &&
+        if (r && r != editedItemRenderer &&
             (lastItemDown == r || (lastItemDown && grid.contains(DisplayObject(lastItemDown)))))
         {
             // if lastItemDown != r, we clicked in one cell and dragged to another.
@@ -1239,34 +1220,31 @@
                 r = lastItemDown;

             lastItemFocused = null;
-            pos = new Point(rowIndex, columnIndex);
-
-            if (pos && pos.y >= 0 && dataGrid.editable && !dontEdit)
+
+            if (columnIndex >= 0 && dataGrid.editable && !dontEdit)
             {
-                if (grid.columns.getItemAt(pos.x).editable)
+                if (grid.columns.getItemAt(columnIndex).editable)
                 {
-                    startItemEditorSession(pos.x, pos.y);
+                    startItemEditorSession(rowIndex, columnIndex);
                 }
                 else
                     // if the item is not editable, set lastPosition to it anyways
                     // so future tabbing starts from there
-                    lastEditedItemPosition = { columnIndex: pos.x, rowIndex: pos.y };
+                    lastEditedItemPosition = { columnIndex: columnIndex, rowIndex: rowIndex };
             }
         }
-        else if (lastItemDown && lastItemDown != itemEditorInstance)
-        {
-            pos = new Point(rowIndex, columnIndex);
-
-            if (pos && pos.y >= 0 && dataGrid.editable && !dontEdit)
+        else if (lastItemDown && lastItemDown != editedItemRenderer)
+        {
+            if (columnIndex >= 0 && dataGrid.editable && !dontEdit)
             {
-                if (grid.columns.getItemAt(pos.x).editable)
+                if (grid.columns.getItemAt(columnIndex).editable)
                 {
-                    startItemEditorSession(pos.x, pos.y);
+                    startItemEditorSession(rowIndex, columnIndex);
                 }
                 else
                     // if the item is not editable, set lastPosition to it anyways
                     // so future tabbing starts from there
-                    lastEditedItemPosition = { columnIndex: pos.x, rowIndex: pos.y };
+                    lastEditedItemPosition = { columnIndex: columnIndex, rowIndex: rowIndex};
             }
         }

@@ -1279,7 +1257,7 @@
      */
     private function itemEditorInstance_FocusOutHandler(event:FocusEvent):void
     {
-        trace("itemEditorInstance_FocusOutHandler " + event.relatedObject);
+        //trace("itemEditorInstance_FocusOutHandler " + event.relatedObject);
         if (event.relatedObject &&
            ((itemEditorInstance && DisplayObjectContainer(itemEditorInstance).contains(event.relatedObject)) ||
            (editedItemRenderer && DisplayObjectContainer(editedItemRenderer).contains(event.relatedObject))) )
@@ -1291,7 +1269,7 @@

         // trace("endEdit from itemEditorFocusOut");
         if (itemEditorInstance || editedItemRenderer)
-            endEdit("DataGridEventReason.OTHER");
+            endEdit();
         else
             destroyItemEditor();

@@ -1326,7 +1304,7 @@
         // we popup an editor again
         if (itemEditorInstance || editedItemRenderer)
         {
-            endEdit("DataGridEventReason.OTHER");
+            endEdit();
             deferFocus();
         }
     }
@@ -1360,7 +1338,7 @@
             // The 229 keyCode is for IME compatability. When entering an IME expression,
             // the enter key is down, but the keyCode is 229 instead of the enter key code.
             // Thanks to Yukari for this little trick...
-            if (endEdit("DataGridEventReason.NEW_ROW"))
+            if (endEdit())
             {
                 //                findNextEnterItemRenderer(event);
                 if (grid.focusManager)
@@ -1391,7 +1369,7 @@
      */
     private function editorAncestorResizeHandler(event:Event):void
     {
-        endEdit("DataGridEventReason.OTHER");
+        endEdit();
     }

     /**
@@ -1411,7 +1389,7 @@
             return;
         }

-        endEdit("DataGridEventReason.OTHER");
+        endEdit();
         // set focus back to the grid so grid logic will deal if focus doesn't
         // end up somewhere else
         deferFocus();
@@ -1427,20 +1405,19 @@
         // if we tabbed out of the edit then prevent the tab and
         // save the edit. Next start up a new edit session in the
         // next cell.
-        // TODO (dloverin): do I need to add the TAB key check here.
-        //                  look at flash bug (workaround in focus managere
-        //                  and handle it if so.
-        trace("keyFocusChangeHandler");
+        //trace("keyFocusChangeHandler");
+
         if (itemEditorInstance || editedItemRenderer)
         {
             var nextObject:IFocusManagerComponent = grid.focusManager.getNextFocusManagerComponent(event.shiftKey);
             if (nextObject == itemEditorInstance ||
                 (itemEditorInstance && !DisplayObjectContainer(itemEditorInstance).contains(DisplayObject(nextObject))) ||
-                nextObject == editedItemRenderer ||
-                (editedItemRenderer && !DisplayObjectContainer(editedItemRenderer).contains(DisplayObject(nextObject))))
+                (!itemEditorInstance &&
+                (nextObject == editedItemRenderer ||
+                (editedItemRenderer && !DisplayObjectContainer(editedItemRenderer).contains(DisplayObject(nextObject))))))
             {
                 event.preventDefault();
-                endEdit("");
+                endEdit();

                 var nextCellPosition:Point = getNextEditableCell(lastEditedItemPosition.rowIndex,
                                                                  lastEditedItemPosition.columnIndex,


Transferred from the Adobe Open Source Subversion Repository

Revision: 6257
Author:   smgilson@adobe.com
Date:     2009-04-24T21:28:52.430843Z

Log Message:
-----------
ASDoc edits for effects

QE Notes: None
Doc Notes: None
Bugs: -
checkintests: passed

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/EaseInOutBase.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/animation/Animation.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/animation/IAnimationTarget.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/IEaser.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/animation/RepeatBehavior.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/Linear.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/AnimateTransformScale.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/EasingFraction.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/Power.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/interpolation/IInterpolator.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/interpolation/NumberInterpolator.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/easing/Sine.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/interpolation/RGBInterpolator.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/interpolation/HSBInterpolator.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/interpolation/ArrayInterpolator.as</path>

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

--- frameworks/projects/spark/src/spark/effects/interpolation/RGBInterpolator.as
+++ frameworks/projects/spark/src/spark/effects/interpolation/RGBInterpolator.as
@@ -11,11 +11,12 @@
 package spark.effects.interpolation
 {
 /**
- * The RGBInterpolator class provides RGB-space interpolation between
- * uint start and end values. Interpolation is done by treating
- * the start and end values as integers with color channel information in
- * the least-significant 3 bytes, interpolating each of those channels
- * separately.
+ *  The RGBInterpolator class provides interpolation between
+ *  uint start and end values that represent RGB colors.
+ *  Interpolation is done by treating
+ *  the start and end values as integers with color channel information in
+ *  the least-significant 3 bytes, and then interpolating each of the channels
+ *  separately.
  *
  *  @langversion 3.0
  *  @playerversion Flash 10
@@ -26,14 +27,22 @@
 {
     private static var theInstance:RGBInterpolator;

+    /**
+     *  Constructor.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
     public function RGBInterpolator()
     {
         super();
     }

     /**
-     * Returns the singleton of this class. Since all RGBInterpolators
-     * have the same behavior, there is no need for more than one instance.
+     *  Returns the singleton of this class. Since all RGBInterpolators
+     *  have the same behavior, there is no need for more than one instance.
      *
      *  @langversion 3.0
      *  @playerversion Flash 10
@@ -48,8 +57,8 @@
     }

     /**
-     * Returns the uint type, which is the type of
-     * object interpolated by RGBInterpolator
+     *  Returns the uint type, which is the type of
+     *  object interpolated by RGBInterpolator
      *
      *  @langversion 3.0
      *  @playerversion Flash 10
@@ -62,14 +71,19 @@
     }

     /**
-     * @inheritDoc
+     *  Interpolation for the RGBInterpolator class takes the form of parametric
+     *  calculations on each of the bottom three bytes of
+     *  startValue and endValue.
      *
-     * The interpolation for RGBInterpolator takes the form of parametric
-     * calculations on each of the bottom three bytes of
-     * startValue and endValue. This interpolates
-     * each color channel separately if the start and end values represent
-     * RGB colors.
-     *
+     *  @param fraction The fraction elapsed of the
+     *  animation, between 0.0 and 1.0.
+     *
+     *  @param startValue The start value of the interpolation.
+     *
+     *  @param endValue The end value of the interpolation.
+     *
+     *  @return The interpolated value.
+     *
      *  @langversion 3.0
      *  @playerversion Flash 10
      *  @playerversion AIR 1.5
@@ -134,11 +148,15 @@
     }

     /**
-     * @inheritDoc
-     *
-     *
This function returns the result of the two values added
-     * together on a per-channel basis. Each channel will be clamped
-     * at 255 to avoid overflow problems.

+     *  Returns the result of the two values added
+     *  together on a per-channel basis. Each channel has a maximum
+     *  value of 255 to avoid overflow problems.
+     *
+     *  @param baseValue The start value of the interpolation.
+     *
+     *  @param incrementValue The change to apply to the baseValue.
+     *
+     *  @return The interpolated value.
      *
      *  @langversion 3.0
      *  @playerversion Flash 10
@@ -151,11 +169,15 @@
     }

     /**
-     * @inheritDoc
-     *
-     *
This function returns the result of the two values subtracted
-     * on a per-channel basis. Each channel will be clamped
-     * at 0 to avoid underflow problems.

+     *  Returns the result of the two values subtracted
+     *  on a per-channel basis. Each channel has a minimum
+     *  value of 0 to avoid underflow problems.
+     *
+     *  @param baseValue The start value of the interpolation.
+     *
+     *  @param decrementValue The change to apply to the baseValue.
+     *
+     *  @return The interpolated value.
      *
      *  @langversion 3.0
      *  @playerversion Flash 10


Fix use of fileSystem.programDir in the terrain editor. Use the resource system / scene resource path instead. Closes #1852.

--- bin/Data/Scripts/Editor/EditorTerrain.as
+++ bin/Data/Scripts/Editor/EditorTerrain.as
@@ -160,7 +160,7 @@
             // Make sure its not null (it may have been deleted since last save)
             if (terrainsEdited[i] !is null)
             {
-                String fileLocation = fileSystem.programDir + "Data/" + terrainsEdited[i].GetAttribute("Height Map").GetResourceRef().name;
+                String fileLocation = sceneResourcePath + terrainsEdited[i].GetAttribute("Height Map").GetResourceRef().name;

                 Array<String> chunks = fileLocation.Split('/');
                 Array<String> parts = chunks[chunks.length - 1].Split('.');
@@ -286,7 +286,7 @@
                 continue;

             return value < (i + (i / 2)) ? i : i * 2;
-    	}
+        }

         return 2048;
     }
@@ -294,7 +294,7 @@
     private void CreateTerrain()
     {
         String fileName = "Textures/heightmap-" + time.timeSinceEpoch  + ".png";
-        String fileLocation = fileSystem.programDir + "Data/" + fileName;
+        String fileLocation = sceneResourcePath + fileName;

         Node@ node = CreateNode(LOCAL);
         node.position = Vector3(0, 0, 0);
@@ -313,6 +313,8 @@

         UpdateTerrainSetConstantHeight(image, 0);

+        if (!fileSystem.DirExists(GetPath(fileLocation)))
+            fileSystem.CreateDir(GetPath(fileLocation));
         image.SavePNG(fileLocation);

         Terrain@ terrain = node.CreateComponent("Terrain");
@@ -384,7 +386,15 @@
     {
         ListView@ terrainBrushes = window.GetChild("BrushesContainer", true);

-        String brushesFileLocation = fileSystem.programDir + "Data/Textures/Editor/TerrainBrushes";
+        Array<String>@ resourceDirs = cache.resourceDirs;
+        String brushesFileLocation;
+        for (uint i = 0; i < resourceDirs.length; ++i)
+        {
+            brushesFileLocation = resourceDirs[i] + "Textures/Editor/TerrainBrushes";
+            if (fileSystem.DirExists(brushesFileLocation))
+                break;
+        }
+
         Array<String> files = fileSystem.ScanDir(brushesFileLocation, "*.*", SCAN_FILES, false);

         for (uint i = 0; i < files.length; ++i)


fixed CubeMapProjectionShaderPart to use Matrix4x4.view() instead of Matrix4x4.lookAt()

--- src/aerys/minko/render/shader/part/projection/CubeMapProjectionShaderPart.as
+++ src/aerys/minko/render/shader/part/projection/CubeMapProjectionShaderPart.as
@@ -17,12 +17,12 @@
 	public class CubeMapProjectionShaderPart extends ShaderPart implements IProjectionShaderPart
 	{
 		private static const VIEW_MATRICES : Vector.<Matrix4x4> = new <Matrix4x4>[
-			new Matrix4x4().lookAt(Vector4.ZERO, Vector4.X_AXIS,		Vector4.Y_AXIS),	 // look at positive x
-			new Matrix4x4().lookAt(Vector4.ZERO, new Vector4(-1, 0, 0),	Vector4.Y_AXIS),	 // look at negative x
-			new Matrix4x4().lookAt(Vector4.ZERO, Vector4.Y_AXIS,		new Vector4(0, 0, -1)),	 // look at positive y
-			new Matrix4x4().lookAt(Vector4.ZERO, new Vector4(0, -1, 0),	Vector4.Z_AXIS),	 // look at negative y
-			new Matrix4x4().lookAt(Vector4.ZERO, Vector4.Z_AXIS,		Vector4.Y_AXIS),	 // look at positive z
-			new Matrix4x4().lookAt(Vector4.ZERO, new Vector4(0, 0, -1),	Vector4.Y_AXIS),	 // look at negative z
+			new Matrix4x4().view(Vector4.ZERO, Vector4.X_AXIS,		Vector4.Y_AXIS),	 // look at positive x
+			new Matrix4x4().view(Vector4.ZERO, new Vector4(-1, 0, 0),	Vector4.Y_AXIS),	 // look at negative x
+			new Matrix4x4().view(Vector4.ZERO, Vector4.Y_AXIS,		new Vector4(0, 0, -1)),	 // look at positive y
+			new Matrix4x4().view(Vector4.ZERO, new Vector4(0, -1, 0),	Vector4.Z_AXIS),	 // look at negative y
+			new Matrix4x4().view(Vector4.ZERO, Vector4.Z_AXIS,		Vector4.Y_AXIS),	 // look at positive z
+			new Matrix4x4().view(Vector4.ZERO, new Vector4(0, 0, -1),	Vector4.Y_AXIS),	 // look at negative z
 		];

 		private var _side : uint;


Transferred from the Adobe Open Source Subversion Repository

Revision: 17005
Author:   rfrishbe@adobe.com
Date:     2010-07-21T22:23:20.505181Z

Log Message:
-----------
Adding IconItemRenderer to SVN.  This makes it easier for others to work with the class.  For now, it's added to mobiletheme: spark.skins.mobile; however, it might move out of the skins and mobiletheme depending on PARB later on (as well as undergo a name-change).

This is still not the default item renderer. That change will come later when the class has been vetted a bit more.

QE notes: None
Doc notes: None
Bugs: -
Reviewer: None - will review with mobile list stuff later
Tests run: checkintests
Is noteworthy for integration: No

Modified Paths:
--------------
<path kind="file" action="M">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/MobileThemeClasses.as</path>
<path kind="file" action="A">/private/flex/sdk/branches/hero_private/frameworks/projects/mobiletheme/src/spark/skins/mobile/IconItemRenderer.as</path>

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

--- frameworks/projects/mobilecomponents/src/spark/components/IconItemRenderer.as
+++ frameworks/projects/mobilecomponents/src/spark/components/IconItemRenderer.as
@@ -0,0 +1,1157 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  ADOBE SYSTEMS INCORPORATED
+//  Copyright 2004-20010 Adobe Systems Incorporated
+//  All Rights Reserved.
+//
+//  NOTICE: Adobe permits you to use, modify, and distribute this file
+//  in accordance with the terms of the license agreement accompanying it.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package spark.skins.mobile
+{
+import flash.display.DisplayObject;
+import flash.events.MouseEvent;
+import flash.geom.Point;
+import flash.text.TextField;
+import flash.text.TextFieldType;
+import flash.text.TextFormat;
+import flash.text.TextFormatAlign;
+import flash.text.TextLineMetrics;
+
+import mx.controls.listClasses.*;
+import mx.core.IDataRenderer;
+import mx.core.IFlexDisplayObject;
+import mx.core.IFlexModuleFactory;
+import mx.core.IVisualElement;
+import mx.core.UIComponent;
+import mx.core.mx_internal;
+import mx.events.FlexEvent;
+import mx.utils.StringUtil;
+
+import spark.components.Group;
+import spark.components.IItemRenderer;
+import spark.components.Image;
+import spark.components.Label;
+import spark.components.supportClasses.TextBase;
+import spark.core.ContentCache;
+import spark.primitives.BitmapImage;
+
+use namespace mx_internal;
+
+//--------------------------------------
+//  Events
+//--------------------------------------
+
+/**
+ *  Dispatched when the data property changes.
+ *
+ *
When you use a component as an item renderer,
+ *  the data property contains the data to display.
+ *  You can listen for this event and update the component
+ *  when the data property changes.

+ *
+ *  @eventType mx.events.FlexEvent.DATA_CHANGE
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Event(name="dataChange", type="mx.events.FlexEvent")]
+
+//--------------------------------------
+//  Styles
+//--------------------------------------
+
+// FIXME(rfrishbe): get these styles somehow
+//include "../../styles/metadata/BasicInheritingTextStyles.as"
+//include "../../styles/metadata/AdvancedInheritingTextStyles.as"
+//include "../../styles/metadata/SelectionFormatTextStyles.as"
+
+/**
+ *  The colors to use for the backgrounds of the items in the list.
+ *  The value is an array of two or more colors.
+ *  The backgrounds of the list items alternate among the colors in the array.
+ *
+ *  @default undefined
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Style(name="alternatingItemColors", type="Array", arrayType="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ *  Color of focus ring when the component is in focus
+ *
+ *  @default 0x70B2EE
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Style(name="focusColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+/**
+ *  Color of the highlights when the mouse is over the component
+ *
+ *  @default 0xCEDBEF
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Style(name="rollOverColor", type="uint", format="Color", inherit="yes")]
+// FIXME (rfrishbe): should be theme="" above
+
+/**
+ *  Color of the highlights when the item is selected
+ *
+ *  @default 0xCEDBEF
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Style(name="selectionColor", type="uint", format="Color", inherit="yes")]
+// FIXME (rfrishbe): figure out why this isn't on defaultitemrenderer or itemrenderer
+
+/**
+ *  Color of any symbol of a component. Examples include the check mark of a CheckBox or
+ *  the arrow of a scroll button
+ *
+ *  @default 0x000000
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 1.5
+ *  @productversion Flex 4
+ */
+[Style(name="symbolColor", type="uint", format="Color", inherit="yes", theme="spark, mobile")]
+
+//--------------------------------------
+//  Excluded APIs
+//--------------------------------------
+
+[Exclude(name="focusBlendMode", kind="style")]
+[Exclude(name="focusThickness", kind="style")]
+
+/**
+ *  The IconItemRenderer class is a performant item
+ *  renderer optimized for mobile devices.  It contains
+ *  an optional icon on the left, text in the middle, and
+ *  an optional decorator icon on the right.
+ *
+ *
You can override the default item renderer
+ *  by creating a custom item renderer.

+ *
+ *  @see spark.components.List
+ *  @see mx.core.IDataRenderer
+ *  @see spark.components.IItemRenderer
+ *  @see spark.components.supportClasses.ItemRenderer
+ *
+ *  @langversion 3.0
+ *  @playerversion Flash 10
+ *  @playerversion AIR 2.5
+ *  @productversion Flex 4.5
+ */
+public class IconItemRenderer extends UIComponent
+    implements IDataRenderer, IItemRenderer
+{
+
+    // Image cache for all instances of this item renderer.
+    static private var _imageCache: ContentCache;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Constructor
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  Constructor.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function IconItemRenderer()
+    {
+        super();
+        addHandlers();
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Variables
+    //
+    //--------------------------------------------------------------------------
+
+    //--------------------------------------------------------------------------
+    //
+    //  Private Properties
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Flag that is set when the mouse is hovered over the item renderer.
+     */
+    private var hovered:Boolean = false;
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden properties: UIComponent
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  baselinePosition
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    override public function get baselinePosition():Number
+    {
+        // Copied from UITextField.baselinePosition
+        var tlm:TextLineMetrics;
+
+        // The text styles aren't known until there is a parent.
+        if (!parent)
+            return NaN;
+
+        // getLineMetrics() returns strange numbers for an empty string,
+        // so instead we get the metrics for a non-empty string.
+        var isEmpty:Boolean = (labelTextField.text == "");
+        if (isEmpty)
+            labelTextField.text = "Wj";
+
+        tlm = labelTextField.getLineMetrics(0);
+
+        if (isEmpty)
+            labelTextField.text = "";
+
+        // TextFields have 2 pixels of padding all around.
+        return 2 + tlm.ascent;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Public Properties
+    //
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    //  data
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var _data:Object;
+
+    /**
+     *  @private
+     */
+    private var dataChanged:Boolean;
+
+    [Bindable("dataChange")]
+
+    /**
+     *  The implementation of the data property
+     *  as defined by the IDataRenderer interface.
+     *  When set, it stores the value and invalidates the component
+     *  to trigger a relayout of the component.
+     *
+     *  @see mx.core.IDataRenderer
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get data():Object
+    {
+        return _data;
+    }
+
+    /**
+     *  @private
+     */
+    public function set data(value:Object):void
+    {
+        _data = value;
+
+        dataChanged = true;
+        invalidateProperties();
+
+        dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
+    }
+
+    //----------------------------------
+    //  decoratorClass
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var _decoratorClass:Class;
+
+    /**
+     *  @private
+     */
+    private var decoratorClassChanged:Boolean;
+
+    /**
+     *  @private
+     */
+    private var decoratorDisplay:DisplayObject;
+
+    /**
+     *  Decorator that appears on the right side
+     *  of this item renderer
+     *
+     *  @default ""
+     */
+    public function get decoratorClass():Class
+    {
+        return _decoratorClass;
+    }
+
+    /**
+     *  @private
+     */
+    public function set decoratorClass(value:Class):void
+    {
+        if (value == _decoratorClass)
+            return;
+
+        _decoratorClass = value;
+
+        decoratorClassChanged = true;
+        invalidateProperties();
+    }
+
+    //----------------------------------
+    //  iconField
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var _iconField:String;
+
+    /**
+     *  @private
+     */
+    private var iconFieldChanged:Boolean;
+
+    /**
+     *  @private
+     */
+    private var iconDisplay:BitmapImage;
+
+    /**
+     *  @private
+     *
+     *  Need a holder for the iconDisplay since it's a GraphicElement
+     *  TODO (rfrishbe): would be nice to fix above somehow
+     */
+    private var iconDisplayHolder:Group;
+
+    /**
+     *  The name of the field in the data provider items to display as the icon.
+     *  By default iconField is null, and the item renderer
+     *  doesn't look for an icon.
+     *
+     *  @default null
+     */
+    public function get iconField():String
+    {
+        return _iconField;
+    }
+
+    /**
+     *  @private
+     */
+    public function set iconField(value:String):void
+    {
+        if (value == _iconField)
+            return;
+
+        _iconField = value;
+        iconFieldChanged = true;
+        dataChanged = true;
+
+        invalidateProperties();
+    }
+
+    //----------------------------------
+    //  iconHeight
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var _iconHeight:Number;
+
+    /**
+     *  The height of the icon.  If nothing is specified, the
+     *  intrinsic height of the image will be used.
+     *
+     *  @default NaN
+     */
+    public function get iconHeight():Number
+    {
+        return _iconHeight;
+    }
+
+    /**
+     *  @private
+     */
+    public function set iconHeight(value:Number):void
+    {
+        if (value == _iconHeight)
+            return;
+
+        _iconHeight = value;
+
+        invalidateSize();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  iconWidth
+    //----------------------------------
+
+    /**
+     *  @private
+     */
+    private var _iconWidth:Number;
+
+    /**
+     *  The width of the icon.  If nothing is specified, the
+     *  intrinsic width of the image will be used.
+     *
+     *  @default NaN
+     */
+    public function get iconWidth():Number
+    {
+        return _iconWidth;
+    }
+
+    /**
+     *  @private
+     */
+    public function set iconWidth(value:Number):void
+    {
+        if (value == _iconWidth)
+            return;
+
+        _iconWidth = value;
+
+        invalidateSize();
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  itemIndex
+    //----------------------------------
+
+    /**
+     *  @private
+     *  storage for the itemIndex property
+     */
+    private var _itemIndex:int;
+
+    /**
+     *  @inheritDoc
+     *
+     *  @default 0
+     */
+    public function get itemIndex():int
+    {
+        return _itemIndex;
+    }
+
+    /**
+     *  @private
+     */
+    public function set itemIndex(value:int):void
+    {
+        if (value == _itemIndex)
+            return;
+
+        _itemIndex = value;
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  label
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage var for label
+     */
+    private var _label:String = "";
+
+    /**
+     *  @private
+     */
+    private var labelTextField:TextField;
+
+    /**
+     *  @private
+     */
+    private var recreateLabelTextFieldStyles:Boolean;
+
+    /**
+     *  @inheritDoc
+     *
+     *  @default ""
+     */
+    public function get label():String
+    {
+        return _label;
+    }
+
+    /**
+     *  @private
+     */
+    public function set label(value:String):void
+    {
+        if (value == _label)
+            return;
+
+        _label = value;
+
+        // Push the label down into the labelTextField,
+        // if it exists
+        if (labelTextField)
+            labelTextField.text = _label;
+    }
+
+    //----------------------------------
+    //  showsCaret
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the showsCaret property
+     */
+    private var _showsCaret:Boolean = false;
+
+    /**
+     *  @inheritDoc
+     *
+     *  @default false
+     */
+    public function get showsCaret():Boolean
+    {
+        return _showsCaret;
+    }
+
+    /**
+     *  @private
+     */
+    public function set showsCaret(value:Boolean):void
+    {
+        if (value == _showsCaret)
+            return;
+
+        _showsCaret = value;
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  selected
+    //----------------------------------
+    /**
+     *  @private
+     *  storage for the selected property
+     */
+    private var _selected:Boolean = false;
+
+    /**
+     *  @inheritDoc
+     *
+     *  @default false
+     */
+    public function get selected():Boolean
+    {
+        return _selected;
+    }
+
+    /**
+     *  @private
+     */
+    public function set selected(value:Boolean):void
+    {
+        if (value == _selected)
+            return;
+
+        _selected = value;
+        invalidateDisplayList();
+    }
+
+    //----------------------------------
+    //  dragging
+    //----------------------------------
+
+    /**
+     *  @private
+     *  Storage for the dragging property.
+     */
+    private var _dragging:Boolean = false;
+
+    /**
+     *  @inheritDoc
+     */
+    public function get dragging():Boolean
+    {
+        return _dragging;
+    }
+
+    /**
+     *  @private
+     */
+    public function set dragging(value:Boolean):void
+    {
+        if (value == _dragging)
+            return;
+
+        _dragging = value;
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Overridden methods: UIComponent
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     */
+    override protected function createChildren():void
+    {
+        super.createChildren();
+
+        if (!labelTextField)
+        {
+            labelTextField = new TextField();
+            labelTextField.multiline = false;
+            labelTextField.wordWrap = false;
+            labelTextField.selectable = false;
+
+            addChild(DisplayObject(labelTextField));
+            if (_label != "")
+                labelTextField.text = _label;
+
+            recreateLabelTextFieldStyles = true;
+            invalidateProperties();
+        }
+
+        // iconDisplay and decoratorClass are created in
+        // commitProperties()
+    }
+
+    /**
+     *  @private
+     */
+    override protected function commitProperties():void
+    {
+        super.commitProperties();
+
+        if (decoratorClassChanged)
+        {
+            decoratorClassChanged = false;
+
+            // if there's an old one, remove it
+            if (decoratorDisplay)
+            {
+                removeChild(decoratorDisplay);
+            }
+
+            // if we need to create it, do it here
+            if (decoratorClass)
+            {
+                decoratorDisplay = new _decoratorClass();
+                addChild(decoratorDisplay);
+            }
+
+            invalidateSize();
+            invalidateDisplayList();
+        }
+
+        if (iconFieldChanged)
+        {
+            iconFieldChanged = false;
+
+            // let's see if we need to create or remove it
+            if (iconField && !iconDisplay)
+            {
+                // need to create it
+                iconDisplayHolder = new Group();
+
+                iconDisplay = new BitmapImage();
+                iconDisplay.left = 0;
+                iconDisplay.right = 0;
+                iconDisplay.top = 0;
+                iconDisplay.bottom = 0;
+                //				iconDisplay.setStyle("backgroundColor", 0xC0C0C0);
+
+                if (_imageCache == null) {
+                    _imageCache = new ContentCache();
+                    _imageCache.maxCacheEntries = 100;
+                }
+                iconDisplay.contentLoader = _imageCache;
+
+                // add iconDisplayHolder to the display list first in case
+                // bitmap needs to check its layoutDirection.
+                addChild(iconDisplayHolder);
+                iconDisplayHolder.addElement(iconDisplay);
+            }
+            else if (!iconField && iconDisplay)
+            {
+                // need to remove it
+                removeChild(iconDisplayHolder);
+                iconDisplayHolder.removeElement(iconDisplay);
+                iconDisplayHolder = null;
+                iconDisplay = null;
+            }
+
+            invalidateSize();
+            invalidateDisplayList();
+        }
+
+        if (dataChanged)
+        {
+            dataChanged = false;
+
+            // if an iconField, try setting that
+            if (iconField)
+            {
+                try
+                {
+                    if (iconField in data && data[iconField] != null)
+                    {
+                        iconDisplay.source = data[iconField];
+                    }
+                }
+                catch(e:Error)
+                {
+                }
+            }
+
+            invalidateSize();
+            invalidateDisplayList();
+        }
+
+        if (recreateLabelTextFieldStyles)
+        {
+            recreateLabelTextFieldStyles = false;
+
+            var textFormat:TextFormat = getTextStyles();
+
+            // FIXME (rfrishbe): should deal with embedded fonts better
+
+            labelTextField.defaultTextFormat = textFormat;
+
+            // need to set text here for the defaultTextFormat to take effect
+            labelTextField.text = labelTextField.text;
+
+            invalidateSize();
+            invalidateDisplayList();
+        }
+    }
+
+    /**
+     *  @private
+     *  Defined by what we use in getTextStyles();
+     */
+    private static const TEXT_CSS_STYLES:Object =
+        {textAlign: true,
+            fontWeight: true,
+            color: true,
+            disabledColor: true,
+            fontFamily: true,
+            textIndent: true,
+            fontStyle: true,
+            kerning: true,
+            leading: true,
+            letterSpacing: true,
+            fontSize: true,
+            textDecoration: true};
+
+    /**
+     *  Returns the TextFormat object that represents
+     *  character formatting information for this UITextField object.
+     *
+     *  @return A TextFormat object.
+     *
+     *  @see flash.text.TextFormat
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function getTextStyles():TextFormat
+    {
+        // Adapted from UITextField.getTextStyles()
+        var textFormat:TextFormat = new TextFormat();
+
+        var textAlign:String = getStyle("textAlign");
+
+        if (textAlign == "start")
+            textAlign = TextFormatAlign.LEFT;
+        else if (textAlign == "end")
+            textAlign = TextFormatAlign.RIGHT;
+        textFormat.align = textAlign;
+        textFormat.bold = getStyle("fontWeight") == "bold";
+        if (enabled)
+            textFormat.color = getStyle("color");
+        else
+            textFormat.color = getStyle("disabledColor");
+        textFormat.font = StringUtil.trimArrayElements(getStyle("fontFamily"),",");
+        textFormat.indent = getStyle("textIndent");
+        textFormat.italic = getStyle("fontStyle") == "italic";
+        var kerning:* = getStyle("kerning");
+        // In Halo components based on TextField,
+        // kerning is supposed to be true or false.
+        // The default in TextField and Flex 3 is false
+        // because kerning doesn't work for device fonts
+        // and is slow for embedded fonts.
+        // In Spark components based on TLF and FTE,
+        // kerning is "auto", "on", or, "off".
+        // The default in TLF and FTE is "auto"
+        // (which means kern non-Asian characters)
+        // because kerning works even on device fonts
+        // and has miminal performance impact.
+        // Since a CSS selector or parent container
+        // can affect both Halo and Spark components,
+        // we need to map "auto" and "on" to true
+        // and "off" to false for Halo components
+        // here and in UIFTETextField.
+        // For Spark components, Label and CSSTextLayoutFormat,
+        // do the opposite mapping of true to "on" and false to "off".
+        // We also support a value of "default"
+        // (which we set in the global selector)
+        // to mean false for Halo and "auto" for Spark,
+        // to get the recommended behavior in both sets of components.
+        if (kerning == "auto" || kerning == "on")
+            kerning = true;
+        else if (kerning == "default" || kerning == "off")
+            kerning = false;
+        textFormat.kerning = kerning;
+        textFormat.leading = getStyle("leading");
+        //textFormat.leftMargin = ignorePadding ? 0 : getStyle("paddingLeft");
+        textFormat.letterSpacing = getStyle("letterSpacing");
+        //textFormat.rightMargin = ignorePadding ? 0 : getStyle("paddingRight");
+        textFormat.size = getStyle("fontSize");
+        textFormat.underline = getStyle("textDecoration") == "underline";
+
+        return textFormat;
+    }
+
+    /**
+     *  @private
+     */
+    override protected function measure():void
+    {
+        super.measure();
+
+        // start them at 0, then go through icon, label, and decorator
+        // and add to these
+        var myMeasuredWidth:Number = 0;
+        var myMeasuredHeight:Number = 0;
+        var myMeasuredMinWidth:Number = 0;
+        var myMeasuredMinHeight:Number = 0;
+
+        // Icon is on left
+        if (iconDisplay)
+        {
+            // padding of 5 on the right...left will be accounted for in the label
+            // padding of 10 for height (5 & 5)
+            myMeasuredWidth += (isNaN(iconWidth) ? iconDisplay.getPreferredBoundsWidth() : iconWidth) + 5;
+            myMeasuredHeight = Math.max(myMeasuredHeight, (isNaN(iconHeight) ? iconDisplay.getPreferredBoundsHeight() : iconHeight) + 10);
+            myMeasuredMinWidth += (isNaN(iconWidth) ? iconDisplay.getMinBoundsWidth() : iconWidth) + 5;
+            myMeasuredMinHeight += Math.max(myMeasuredMinHeight, (isNaN(iconHeight) ? iconDisplay.getMinBoundsHeight() : iconHeight) + 10);
+        }
+
+        // Text is aligned next to icon
+
+        // FIXME (rfrishbe): will need to change this calculation
+        // don't allow text to contribute to width for now
+        myMeasuredWidth += labelTextField.textWidth + 5 + 20; // 5 is the extra padding for text field, 20 is normal padding (10 & 10)
+        myMeasuredHeight = Math.max(myMeasuredHeight, labelTextField.textHeight + 4 + 10); // 4 is the extra padding for text field, 10 is normal padding (5 & 5)
+
+        // don't do anything with regards to minimum for the textField
+
+        // Decorator is up next
+        if (decoratorDisplay)
+        {
+            // padding of 5 on the left...the right is already accounted for in the label
+            // padding of 10 for height (5 on top, 5 on bottom)
+            if (decoratorDisplay is IVisualElement)
+            {
+                myMeasuredWidth += IVisualElement(decoratorDisplay).getPreferredBoundsWidth() + 5;
+                myMeasuredHeight = Math.max(myMeasuredHeight, IVisualElement(decoratorDisplay).getPreferredBoundsHeight() + 10);
+                myMeasuredMinWidth += IVisualElement(decoratorDisplay).getMinBoundsWidth() + 5;
+                myMeasuredMinHeight = Math.max(myMeasuredMinHeight, IVisualElement(decoratorDisplay).getMinBoundsHeight() + 10);
+            }
+            else if (decoratorDisplay is IFlexDisplayObject)
+            {
+                myMeasuredWidth += IFlexDisplayObject(decoratorDisplay).measuredWidth + 5;
+                myMeasuredHeight = Math.max(myMeasuredHeight, IFlexDisplayObject(decoratorDisplay).measuredHeight + 10);
+                myMeasuredMinWidth += IFlexDisplayObject(decoratorDisplay).measuredWidth + 5;
+                myMeasuredMinHeight = Math.max(myMeasuredMinHeight, IFlexDisplayObject(decoratorDisplay).measuredHeight + 10);
+            }
+        }
+
+        // now set the local variables to the member variables.  Make sure it means our
+        // minimum height of 42
+        measuredWidth = myMeasuredWidth
+        measuredHeight = Math.max(42, myMeasuredHeight);
+
+        measuredMinWidth = myMeasuredMinWidth;
+        measuredMinHeight = Math.max(42, myMeasuredMinHeight);
+    }
+
+    /**
+     *  @private
+     */
+    override protected function updateDisplayList(unscaledWidth:Number,
+                                                  unscaledHeight:Number):void
+    {
+        super.updateDisplayList(unscaledWidth, unscaledHeight);
+
+        graphics.clear();
+
+        // figure out backgroundColor
+        var backgroundColor:uint;
+        var drawBackground:Boolean = true;
+        if (selected)
+            backgroundColor = getStyle("selectionColor");
+        else if (hovered)
+            backgroundColor = getStyle("rollOverColor");
+        else
+        {
+            var alternatingColors:Array = getStyle("alternatingItemColors");
+
+            if (alternatingColors && alternatingColors.length > 0)
+            {
+                // translate these colors into uints
+                styleManager.getColorNames(alternatingColors);
+
+                backgroundColor = alternatingColors[itemIndex % alternatingColors.length];
+            }
+            else
+            {
+                // don't draw background if it is the contentBackgroundColor. The
+                // list skin handles the background drawing for us.
+                drawBackground = false;
+            }
+        }
+
+        // draw cackgroundColor
+        graphics.beginFill(backgroundColor, drawBackground ? 1 : 0);
+
+        if (showsCaret)
+        {
+            graphics.lineStyle(1, getStyle("selectionColor"));
+            graphics.drawRect(0.5, 0.5, unscaledWidth-1, unscaledHeight-1);
+        }
+        else
+        {
+            graphics.lineStyle();
+            graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
+        }
+
+        graphics.endFill();
+
+        // draw seperators: two lines
+        // 1 pixel from bottom
+        graphics.lineStyle(1, 0x1C1C1C);
+        graphics.moveTo(0, unscaledHeight-1);
+        graphics.lineTo(unscaledWidth, unscaledHeight-1);
+
+        // line on the bottom
+        graphics.lineStyle(1, 0x606060);
+        graphics.moveTo(0, unscaledHeight);
+        graphics.lineTo(unscaledWidth, unscaledHeight);
+
+        // start laying out our children now
+        var iconWidth:Number = 0;
+        var iconHeight:Number = 0;
+        var decoratorWidth:Number = 0;
+        var decoratorHeight:Number = 0;
+
+        // icon is on the left
+        if (iconDisplay)
+        {
+            // set the icon's position and size
+            iconDisplayHolder.setLayoutBoundsSize(this.iconWidth, this.iconHeight);
+
+            iconWidth = iconDisplay.getLayoutBoundsWidth();
+            iconHeight = iconDisplay.getLayoutBoundsHeight();
+
+            // three from the left and center vertically
+            iconDisplayHolder.setLayoutBoundsPosition(10, (unscaledHeight - iconHeight)/2);
+        }
+
+        // decorator is aligned next to icon
+        if (decoratorDisplay)
+        {
+            if (decoratorDisplay is IVisualElement)
+            {
+                var decoratorVisualElement:IVisualElement = IVisualElement(decoratorDisplay);
+                decoratorVisualElement.setLayoutBoundsSize(NaN, NaN);
+
+                decoratorWidth = decoratorVisualElement.getLayoutBoundsWidth();
+                decoratorHeight = decoratorVisualElement.getLayoutBoundsHeight();
+
+                // three from right and center vertically
+                decoratorVisualElement.setLayoutBoundsPosition(unscaledWidth - 10 - decoratorWidth, (unscaledHeight - decoratorHeight)/2);
+            }
+            else if (decoratorDisplay is IFlexDisplayObject)
+            {
+                decoratorWidth = IFlexDisplayObject(decoratorDisplay).measuredWidth;
+                decoratorHeight = IFlexDisplayObject(decoratorDisplay).measuredHeight;
+
+                IFlexDisplayObject(decoratorDisplay).setActualSize(decoratorWidth, decoratorHeight);
+
+                // three from right and center vertically
+                IFlexDisplayObject(decoratorDisplay).move(unscaledWidth - 10 - decoratorWidth, (unscaledHeight - decoratorHeight)/2);
+            }
+        }
+
+        // text should take up the rest of the space
+        var labelWidth:Number = unscaledWidth - iconWidth - decoratorWidth;
+        labelWidth -= 20; // padding of 10 always on left and right
+
+        // don't forget the extra padding of 5 if these elements exist
+        if (iconDisplay)
+            labelWidth -= 5;
+        if (decoratorDisplay)
+            labelWidth -= 5;
+
+        // padding of 5 from the left
+        var labelX:Number = 10;
+        if (iconDisplay)
+            labelX += iconWidth + 5;
+
+        labelTextField.width = labelWidth;
+        labelTextField.height = labelTextField.textHeight + 4;
+
+        labelTextField.x = labelX;
+        labelTextField.y = (unscaledHeight - labelTextField.height)/2;
+    }
+
+    /**
+     *  @private
+     */
+    override public function styleChanged(styleName:String):void
+    {
+        var allStyles:Boolean = !styleName || styleName == "styleName";
+
+        super.styleChanged(styleName);
+
+        if (allStyles || styleName == "inputMode")
+        {
+            addHandlers();
+        }
+
+        if (allStyles || styleName in TEXT_CSS_STYLES)
+        {
+            recreateLabelTextFieldStyles = true;
+            invalidateProperties();
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    //
+    //  Event handling
+    //
+    //--------------------------------------------------------------------------
+
+    /**
+     *  @private
+     *  Keeps track of whether rollover/rollout events were added
+     *
+     *  We need to be careful about calling add/remove event listener because
+     *  of the reference counting going on in
+     *  super.addEventListener/removeEventListener.
+     */
+    private var rolloverEventsAdded:Boolean = false;
+
+    /**
+     *  @private
+     *  Attach the mouse events.
+     */
+    private function addHandlers():void
+    {
+        if (getStyle("inputMode") == "mouse")
+        {
+            if (!rolloverEventsAdded)
+            {
+                rolloverEventsAdded = true;
+                addEventListener(MouseEvent.ROLL_OVER, itemRenderer_rollOverHandler);
+                addEventListener(MouseEvent.ROLL_OUT, itemRenderer_rollOutHandler);
+            }
+        }
+        else
+        {
+            if (rolloverEventsAdded)
+            {
+                rolloverEventsAdded = false;
+                removeEventListener(MouseEvent.ROLL_OVER, itemRenderer_rollOverHandler);
+                removeEventListener(MouseEvent.ROLL_OUT, itemRenderer_rollOutHandler);
+            }
+        }
+    }
+
+    /**
+     *  @private
+     */
+    private function anyButtonDown(event:MouseEvent):Boolean
+    {
+        var type:String = event.type;
+        return event.buttonDown || (type == "middleMouseDown") || (type == "rightMouseDown");
+    }
+
+    /**
+     *  @private
+     *  Mouse rollOver event handler.
+     */
+    protected function itemRenderer_rollOverHandler(event:MouseEvent):void
+    {
+        if (!anyButtonDown(event))
+        {
+            hovered = true;
+            invalidateDisplayList();
+        }
+    }
+
+    /**
+     *  @private
+     *  Mouse rollOut event handler.
+     */
+    protected function itemRenderer_rollOutHandler(event:MouseEvent):void
+    {
+        hovered = false;
+        invalidateDisplayList();
+    }
+
+}
+
+}


Transferred from the Adobe Open Source Subversion Repository

Revision: 3017
Author:   chaase@adobe.com
Date:     2008-08-27T20:27:30.701511Z

Log Message:
-----------
Fix for SDK-16608 and SDK-16445, plus Animation API cleanup.

I've removed the class and concept of IAnimationTarget, which was a duplicate, and more direct, way of listening to animation events. But to simplify the API, I've eliminated the target concept and, instead, require users of Animation to add themselves as listeners to the various AnimationEvent event types. This fixed SDK-16445 because final values were not being sent to targets, although they were being sent to event listeners (which Animate and other new effects benefit from now).

This also fixes SDK-16608, which was caused by assuming that any target of Fade must have the 'visible' property, which is not necessarily the case (such as for the Fill object).

Reviewed by Glenn
tests: checkintests

Modified Paths:
--------------
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/effects/effectClasses/AnimateInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/effects/effectClasses/FadeInstance.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/effects/Animation.as</path>
<path kind="file" action="D">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/effects/IAnimationTarget.as</path>
<path kind="file" action="M">/flex/sdk/trunk/frameworks/projects/flex4/src/flex/effects/effectClasses/ResizeInstance.as</path>

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

--- frameworks/projects/spark/src/spark/effects/supportClasses/AnimateInstance.as
+++ frameworks/projects/spark/src/spark/effects/supportClasses/AnimateInstance.as
@@ -12,10 +12,10 @@
 package flex.effects.effectClasses
 {
 import flex.effects.Animation;
-import flex.effects.IAnimationTarget;
 import flex.effects.PropertyValuesHolder;
 import flex.effects.easing.IEaser;
 import flex.effects.interpolation.IInterpolator;
+import flex.events.AnimationEvent;

 import mx.core.UIComponent;
 import mx.effects.EffectInstance;
@@ -26,7 +26,7 @@
  * Animate effect. Flex creates an instance of this class when
  * it plays a Animate effect; you do not create one yourself.
  */
-public class AnimateInstance extends EffectInstance implements IAnimationTarget
+public class AnimateInstance extends EffectInstance
 {
     public var animation:Animation;

@@ -307,13 +307,15 @@
             // Create the single Animation that will interpolate all properties
             // simultaneously by interpolating the elements of the
             // from/toVals arrays
-            animation = new Animation(fromVals, toVals, duration, this);
+            animation = new Animation(fromVals, toVals, duration);
         }
         else
         {
             // Only one property; don't bother with the arrays
-            animation = new Animation(fromValue, toValue, duration, this);
-        }
+            animation = new Animation(fromValue, toValue, duration);
+        }
+        animation.addEventListener(AnimationEvent.ANIMATION_UPDATE, updateHandler);
+        animation.addEventListener(AnimationEvent.ANIMATION_END, endHandler);

         if (_seekTime > 0)
             animation.seek(_seekTime);
@@ -359,27 +361,19 @@
         }
     }

-    public function animationStart(animation:Animation, value:Object):void
-    {
-    }
-
     /**
      * Handles update events from the animation.
      */
-    public function animationUpdate(animation:Animation, value:Object):void
-    {
-        setVals(value);
-    }
-
-    public function animationRepeat(animation:Animation, value:Object):void
-    {
+    protected function updateHandler(event:AnimationEvent):void
+    {
+        setVals(event.value);
     }

     /**
      * Handles the end event from the animation. The value here is an Array of
      * values, one for each 'property' in our propertyValuesList.
      */
-    public function animationEnd(animation:Animation, value:Object):void
+    protected function endHandler(event:AnimationEvent):void
     {
         finishEffect();
     }


Added dirty() updates for changed properties in BITMAP mode
Removed mask shape used for covering text

git-svn-id: 6aa7ccb0a2048310a30f08a72aaff4ca39d980ed@149 91848ab2-c4ae-4e4f-8e6a-6a52ea0dccc3

--- flare.util/flare/display/TextSprite.as
+++ flare.util/flare/display/TextSprite.as
@@ -74,7 +74,6 @@

 		private var _mode:int = -1;
 		private var _bmap:Bitmap;
-		private var _mask:Shape;
 		private var _tf:TextField;
 		private var _fmt:TextFormat;
 		private var _locked:Boolean = false;
@@ -82,37 +81,6 @@

 		private var _hAnchor:int = LEFT;
 		private var _vAnchor:int = TOP;
-
-		/**
-		 * Gets the alpha value for a rectangular mask shape that is present
-		 * when the text mode is DEVICE.
-		 */
-		public function get maskAlpha():Number {
-			return _mask != null ? _mask.alpha : NaN;
-		}
-		/**
-		 * Sets the alpha value for a rectangular mask shape that is present
-		 * when the text mode is DEVICE.
-		 */
-		public function set maskAlpha(a:Number):void {
-			if (_mask != null) _mask.alpha = a;
-		}
-
-		/**
-		 * Gets the fill color for a rectangular mask shape that is present
-		 * when the text mode is DEVICE.
-		 */
-		public function get maskColor():uint { return _maskColor; }
-		/**
-		 * Sets the fill color for a rectangular mask shape that is present
-		 * when the text mode is DEVICE.
-		 */
-		public function set maskColor(c:uint):void {
-			if (_maskColor != c) {
-				_maskColor = c;
-				if (_mode == DEVICE) dirty();
-			}
-		}

 		/**
 		 * The TextField instance backing this TextSprite.
@@ -147,6 +115,7 @@
 		public function set font(f:String):void {
 			_fmt.font = f;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -156,6 +125,7 @@
 		public function set color(c:uint):void {
 			_fmt.color = c;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -165,6 +135,7 @@
 		public function set size(s:Number):void {
 			_fmt.size = s;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -174,6 +145,7 @@
 		public function set bold(b:Boolean):void {
 			_fmt.bold = b;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -183,6 +155,7 @@
 		public function set italic(b:Boolean):void {
 			_fmt.italic = b;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -192,6 +165,7 @@
 		public function set underline(b:Boolean):void {
 			_fmt.underline = b;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -201,6 +175,7 @@
 		public function set kerning(b:Boolean):void {
 			_fmt.kerning = b;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -210,6 +185,7 @@
 		public function set letterSpacing(s:int):void {
 			_fmt.letterSpacing = s;
 			_tf.setTextFormat(_fmt);
+			if (_mode==BITMAP) dirty();
 		}

 		/**
@@ -262,11 +238,7 @@
 					break;
 				case EMBED:
 					_tf.embedFonts = false;
-					removeChild(_tf);
-					break;
 				case DEVICE:
-					_mask = null;
-					removeChild(_mask);
 					removeChild(_tf);
 					break;
 			}
@@ -277,13 +249,9 @@
 					break;
 				case EMBED:
 					_tf.embedFonts = true;
+				case DEVICE:
 					addChild(_tf);
 					break;
-				case DEVICE:
-					_mask = new Shape(); drawMask(); _mask.alpha = 0;
-					addChild(_tf);
-					addChild(_mask);
-					break;
 			}
 			_mode = mode;
 		}
@@ -293,8 +261,6 @@
 		{
 			if (_mode == BITMAP) {
 				rasterize();
-			} else if (_mode == DEVICE) {
-				drawMask();
 			}
 			layout();
 		}
@@ -314,16 +280,6 @@
 				case MIDDLE: d.y = -d.height / 2; break;
 				case BOTTOM: d.y = -d.height; break;
 			}
-		}
-
-		/** @private */
-		protected function drawMask():void
-		{
-			_mask.graphics.clear();
-			var r:Rectangle = _tf.getBounds(this);
-			_mask.graphics.beginFill(_maskColor);
-			_mask.graphics.drawRect(r.x, r.y, r.width, r.height);
-			_mask.graphics.endFill();
 		}

 		/** @private */