You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/07/06 08:29:11 UTC

[1/2] git commit: [flex-sdk] [refs/heads/develop] - changes to try to get mobile tests to pass

Updated Branches:
  refs/heads/develop aeed464ca -> 4b9bbd9cc


changes to try to get mobile tests to pass


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/4b9bbd9c
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/4b9bbd9c
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/4b9bbd9c

Branch: refs/heads/develop
Commit: 4b9bbd9cc51907a46dc694038d59cb816b85162a
Parents: 6907ac0
Author: Alex Harui <ah...@apache.org>
Authored: Fri Jul 5 23:27:05 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jul 5 23:29:02 2013 -0700

----------------------------------------------------------------------
 .../supportClasses/StyleableTextField.as          |  17 +++++++++++++++--
 .../ImageScaling_bitmapImage_embedded@240ppi.png  | Bin 0 -> 679 bytes
 ...ImageScaling_bitmapImage_referenced@240ppi.png | Bin 0 -> 679 bytes
 .../ImageScaling_button_embedded@240ppi.png       | Bin 0 -> 679 bytes
 .../ImageScaling_button_referenced@240ppi.png     | Bin 0 -> 679 bytes
 ...iconItemRenderer_decorator_embedded@240ppi.png | Bin 0 -> 825 bytes
 .../ImageScaling_image_embedded@240ppi.png        | Bin 0 -> 679 bytes
 .../ImageScaling_image_referenced@240ppi.png      | Bin 0 -> 679 bytes
 ...caling_tabbedViewNavigator_embedded@240ppi.png | Bin 0 -> 994 bytes
 ...ling_tabbedViewNavigator_referenced@240ppi.png | Bin 0 -> 994 bytes
 .../baselines/Check_bitmap_480@android_240ppi.png | Bin 0 -> 264 bytes
 .../List/integration/List_Integration_button.mxml |   8 ++++----
 .../TextArea/Methods/TextArea_Methods_tester.mxml |   5 +++--
 13 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableTextField.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableTextField.as b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableTextField.as
index 8b62d4f..cb18e8d 100644
--- a/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableTextField.as
+++ b/frameworks/projects/mobilecomponents/src/spark/components/supportClasses/StyleableTextField.as
@@ -1219,7 +1219,6 @@ public class StyleableTextField extends FlexTextField
         // could be due to rounding error.  Let's check that it's not.
         // Examples of rounding errors happen with "South Africa" and "Game"
         // with verdana.ttf.
-        
         if (originalText != "" && measuredTextSize.x > w + 0.00000000000001)
         {
             // This should get us into the ballpark.
@@ -1235,7 +1234,21 @@ public class StyleableTextField extends FlexTextField
                 
                 invalidateTextSizeFlag = true;
             }
-            
+            var otl:int = originalText.length;
+            var t:String = s;
+            while (t.length < otl)
+            {
+                t = originalText.slice(0, t.length + 1);
+                super.text = t + truncationIndicator;
+                invalidateTextSizeFlag = true;
+                if (measuredTextSize.x + TEXT_WIDTH_PADDING <= w)
+                    s = t;
+                else
+                    break;
+            } 
+            if (s.length > 0)
+                super.text = s + truncationIndicator;
+
             _isTruncated = true;
             invalidateBaselinePosition = true;
             invalidateTightTextHeight = true;

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_embedded@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_embedded@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_embedded@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_embedded@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_referenced@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_referenced@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_referenced@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_bitmapImage_referenced@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_embedded@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_embedded@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_embedded@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_embedded@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_referenced@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_referenced@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_referenced@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_button_referenced@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_iconItemRenderer_decorator_embedded@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_iconItemRenderer_decorator_embedded@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_iconItemRenderer_decorator_embedded@240ppi.png
new file mode 100644
index 0000000..9c4aba7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_iconItemRenderer_decorator_embedded@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_embedded@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_embedded@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_embedded@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_embedded@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_referenced@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_referenced@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_referenced@240ppi.png
new file mode 100644
index 0000000..a7bf6f7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_image_referenced@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_embedded@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_embedded@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_embedded@240ppi.png
new file mode 100644
index 0000000..5de65b7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_embedded@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_referenced@240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_referenced@240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_referenced@240ppi.png
new file mode 100644
index 0000000..5de65b7
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/integration/baselines/ImageScaling_tabbedViewNavigator_referenced@240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/DensityIndependentScaling/tests/baselines/Check_bitmap_480@android_240ppi.png
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/DensityIndependentScaling/tests/baselines/Check_bitmap_480@android_240ppi.png b/mustella/tests/mobile/DensityIndependentScaling/tests/baselines/Check_bitmap_480@android_240ppi.png
new file mode 100644
index 0000000..82e9755
Binary files /dev/null and b/mustella/tests/mobile/DensityIndependentScaling/tests/baselines/Check_bitmap_480@android_240ppi.png differ

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/components/List/integration/List_Integration_button.mxml
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/components/List/integration/List_Integration_button.mxml b/mustella/tests/mobile/components/List/integration/List_Integration_button.mxml
index b87ed82..fc81184 100644
--- a/mustella/tests/mobile/components/List/integration/List_Integration_button.mxml
+++ b/mustella/tests/mobile/components/List/integration/List_Integration_button.mxml
@@ -152,7 +152,7 @@
                 <SimulateMouseGesture target="navigator.activeView.target" dragYFrom="75" dragYTo="75" dragXFrom="190" dragXTo="140" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="verticalScrollPosition" value="0" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="horizontalScrollPosition" value="0" />
-                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="0" />
+                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="1" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnClickedOutput" value="Not Clicked" />
             </body>
         </TestCase>
@@ -259,7 +259,7 @@
                 <SimulateMouseGesture target="navigator.activeView.target" dragYFrom="125" dragYTo="125" dragXFrom="175" dragXTo="125" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="verticalScrollPosition" value="0" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="horizontalScrollPosition" value="0" />
-                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="0" />
+                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="1" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnChangedOutput" value="Not Changed" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnClickedOutput" value="Not Clicked" />
             </body>
@@ -371,7 +371,7 @@
                 <SimulateMouseGesture target="navigator.activeView.target" dragYFrom="125" dragYTo="125" dragXFrom="175" dragXTo="125" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="verticalScrollPosition" value="0" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="horizontalScrollPosition" value="0" />
-                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="0" />
+                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="1" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnChangedOutput" value="Not Changed" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnClickedOutput" value="Not Clicked" />
             </body>
@@ -507,7 +507,7 @@
                 <SimulateMouseGesture target="navigator.activeView.target" dragYFrom="75" dragYTo="75" dragXFrom="125" dragXTo="75" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="verticalScrollPosition" value="0" />
                 <AssertPropertyValue target="navigator.activeView.target.dataGroup" propertyName="horizontalScrollPosition" value="0" />
-                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="0" />
+                <AssertPropertyValue target="navigator.activeView.target.selectedItems" propertyName="length" value="1" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnChangedOutput" value="Not Changed" />
                 <AssertPropertyValue target="navigator.activeView" propertyName="btnClickedOutput" value="Not Clicked" />
             </body>

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/4b9bbd9c/mustella/tests/mobile/components/TextArea/Methods/TextArea_Methods_tester.mxml
----------------------------------------------------------------------
diff --git a/mustella/tests/mobile/components/TextArea/Methods/TextArea_Methods_tester.mxml b/mustella/tests/mobile/components/TextArea/Methods/TextArea_Methods_tester.mxml
index 25147ba..528e6b6 100644
--- a/mustella/tests/mobile/components/TextArea/Methods/TextArea_Methods_tester.mxml
+++ b/mustella/tests/mobile/components/TextArea/Methods/TextArea_Methods_tester.mxml
@@ -438,12 +438,13 @@
 			<SetProperty target="tac1.ta1" propertyName="width" value="300" />
 			<SetProperty target="tac1.ta1" propertyName="height" value="200" waitEvent="updateComplete" />
 			<SetProperty target="tac1.ta1" propertyName="text" value="The quick brown fox jumped over the lazy dog." waitTarget="tac1.ta1" waitEvent="updateComplete" />
-			<RunCode code="FlexGlobals.topLevelApplication.tac1.ta1.setFocus()" waitTarget="tac1.ta1" />
+			<RunCode code="FlexGlobals.topLevelApplication.tac1.ta1.setFocus()" waitTarget="tac1.ta1" waitEvent="focusIn"/>
 
 		</setup>
 		<body>
 			<RunCode code="FlexGlobals.topLevelApplication.tac1.ta1.selectRange(NaN,NaN)" waitTarget="tac1.ta1" />
-			<Pause timeout="10000" />
+            <WaitForLayoutManager />
+			<WaitForEvent eventName="enterFrame" />
 			<AssertPropertyValue target="tac1.ta1" propertyName="selectionAnchorPosition" value="0" />
 			<!--<AssertPropertyValue target="tac1.ta1" propertyName="selectionActivePosition" value="0" />-->
 			<CompareBitmap numColorVariances="100" ignoreMaxColorVariance="true" url="../Methods/baselines" target="tac1.ta1">


Re: [2/2] git commit: [flex-sdk] [refs/heads/develop] - support mxml.children-as-data mainstream SDK

Posted by Alex Harui <ah...@adobe.com>.

On 7/6/13 3:14 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>Is there any overhead for existing applications?
Just a test to see if the Falcon property is null or not.

>Are there there any tests?
The mustella tests pass using MXMLC which means that it "did no harm".
All kinds of things fail when you try to use Falcon, but I wanted to get
it in so as we start fixing Falcon we can test out the new codegen as well
as the old.

>How about some examples of how to use it.
It's all internal codegen and turned on when you set
-compiler.mxml.children-as-data when using Falcon.

>IMO It seems a rather large change to be committed to the SDK without any
>discussion or explanation.
Yeah, I should have sent out a heads up.  But 4.10 won't be using any of
its code paths so I think it isn't that large a change until we start
using Falcon.  What actually happened was that Git fooled me again.  I had
a few minutes to fix the mobile tests, updated jenkins.sh and this stuff
got pushed unintentionally, although I had planned to push it soon.  I'll
try to be more careful next time.

-Alex


Re: [2/2] git commit: [flex-sdk] [refs/heads/develop] - support mxml.children-as-data mainstream SDK

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

Is there any overhead for existing applications?  Are there there any tests? How about some examples of how to use it. IMO It seems a rather large change to be committed to the SDK without any discussion or explanation.

Justin

Re: [2/2] git commit: [flex-sdk] [refs/heads/develop] - support mxml.children-as-data mainstream SDK

Posted by Alex Harui <ah...@adobe.com>.
No, this was the original plan for Falcon even at Adobe.  The idea is to
convert MXML to data structures so that the compiler is not dependent on
particular versions of the SDK and thus folks can tweak the behavior of
Flex without needing to know how to modify the compiler sources.

Regarding Vanilla, I would love to see folks add more and more of the APIs
in the current Flex SDK to the FlexJS controls as beads.

-Alex

On 7/6/13 7:48 AM, "Erik de Bruin" <er...@ixsoftware.nl> wrote:

>Daring move... what are you trying to achieve? Are you attempting to
>get some kind of "vanilla SDK" support going for FlexJS?
>
>EdB
>
>
>
>On Sat, Jul 6, 2013 at 8:29 AM,  <ah...@apache.org> wrote:
>> support mxml.children-as-data mainstream SDK
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/6907ac09
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/6907ac09
>> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/6907ac09
>>
>> Branch: refs/heads/develop
>> Commit: 6907ac09e43f1df07af558964946316dddefd829
>> Parents: aeed464
>> Author: Alex Harui <ah...@apache.org>
>> Authored: Thu Jun 27 23:34:51 2013 -0700
>> Committer: Alex Harui <ah...@apache.org>
>> Committed: Fri Jul 5 23:29:02 2013 -0700
>>
>> ----------------------------------------------------------------------
>>  .../framework/src/mx/core/UIComponent.as        | 256
>>++++++++++++++++++-
>>  .../framework/src/mx/states/AddItems.as         | 186 +++++++++++++-
>>  .../projects/mx/src/mx/containers/ViewStack.as  |   9 +
>>  frameworks/projects/mx/src/mx/core/Container.as |   6 +-
>>  .../spark/src/spark/components/Group.as         |  10 +-
>>  .../src/spark/components/SkinnableContainer.as  |  31 +++
>>  6 files changed, 492 insertions(+), 6 deletions(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/framework/src/mx/core/UIComponent.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/framework/src/mx/core/UIComponent.as
>>b/frameworks/projects/framework/src/mx/core/UIComponent.as
>> index 8e46058..4eb4a6f 100644
>> --- a/frameworks/projects/framework/src/mx/core/UIComponent.as
>> +++ b/frameworks/projects/framework/src/mx/core/UIComponent.as
>> @@ -1723,6 +1723,11 @@ public class UIComponent extends FlexSprite
>>
>>          _width = super.width;
>>          _height = super.height;
>> +
>> +        var attributes:Array =  this.MXMLProperties;
>> +        if (attributes)
>> +            generateMXMLAttributes(attributes);
>> +
>>      }
>>
>>
>>//-----------------------------------------------------------------------
>>---
>> @@ -4425,6 +4430,44 @@ public class UIComponent extends FlexSprite
>>      {
>>          return document == this;
>>      }
>> +
>> +    //----------------------------------
>> +    //  MXML Descriptor
>> +    //----------------------------------
>> +
>> +    /**
>> +     *  The descriptor of MXML children.
>> +     */
>> +    private var _MXMLDescriptor:Array;
>> +
>> +    public function get MXMLDescriptor():Array
>> +    {
>> +        return _MXMLDescriptor;
>> +    }
>> +
>> +    public function setMXMLDescriptor(value:Array):void
>> +    {
>> +        _MXMLDescriptor = value;
>> +    }
>> +
>> +    //----------------------------------
>> +    //  MXML Properties
>> +    //----------------------------------
>> +
>> +    /**
>> +     *  The attributes of MXML top tag.
>> +     */
>> +    private var _MXMLProperties:Array;
>> +
>> +    public function get MXMLProperties():Array
>> +    {
>> +        return _MXMLProperties;
>> +    }
>> +
>> +    public function setMXMLProperties(value:Array):void
>> +    {
>> +        _MXMLProperties = value;
>> +    }
>>
>>      //----------------------------------
>>      //  parentApplication
>> @@ -7763,8 +7806,219 @@ public class UIComponent extends FlexSprite
>>       */
>>      protected function createChildren():void
>>      {
>> +        var children:Array =  this.MXMLDescriptor;
>> +        if (children)
>> +            generateMXMLInstances(document, children);
>> +    }
>> +
>> +    protected function addMXMLChildren(comps:Array):void
>> +    {
>> +        for each (var i:DisplayObject in comps)
>> +        {
>> +            addChild(i);
>> +        }
>> +    }
>> +
>> +    protected function generateMXMLObject(document:Object,
>>data:Array):Object
>> +    {
>> +        var i:int = 0;
>> +        var cls:Class = data[i++];
>> +        var comp:Object = new cls();
>> +
>> +        var m:int;
>> +        var j:int;
>> +        var name:String;
>> +        var simple:*;
>> +        var value:Object;
>> +        var id:String;
>> +
>> +        m = data[i++]; // num props
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            simple = data[i++];
>> +            value = data[i++];
>> +            if (simple == null)
>> +                value = generateMXMLArray(document, value as Array);
>> +            else if (simple == false)
>> +                value = generateMXMLObject(document, value as Array);
>> +            if (name == "id")
>> +            {
>> +                document[value] = comp;
>> +                id = value as String;
>> +            }
>> +            else if (name == "_id")
>> +            {
>> +                document[value] = comp;
>> +                id = value as String;
>> +                continue; // skip assignment to comp
>> +            }
>> +            comp[name] = value;
>> +        }
>> +        if (comp is IMXMLObject)
>> +            comp.initialized(document, id);
>> +        return comp;
>> +    }
>> +
>> +    public function generateMXMLArray(document:Object, data:Array,
>>recursive:Boolean = true):Array
>> +    {
>> +        var comps:Array = [];
>> +
>> +        var n:int = data.length;
>> +        var i:int = 0;
>> +        while (i < n)
>> +        {
>> +            var cls:Class = data[i++];
>> +            var comp:Object = new cls();
>> +
>> +            var m:int;
>> +            var j:int;
>> +            var name:String;
>> +            var simple:*;
>> +            var value:Object;
>> +            var id:String = null;
>> +
>> +            m = data[i++]; // num props
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(document, value as
>>Array, recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(document, value as
>>Array);
>> +                if (name == "id")
>> +                    id = value as String;
>> +                if (name == "document" && !comp.document)
>> +                    comp.document = document;
>> +                else if (name == "_id")
>> +                    id = value as String; // and don't assign to comp
>> +                else
>> +                    comp[name] = value;
>> +            }
>> +            m = data[i++]; // num styles
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(document, value as
>>Array, recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(document, value as
>>Array);
>> +                comp.setStyle(name, value);
>> +            }
>> +
>> +            m = data[i++]; // num effects
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(document, value as
>>Array, recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(document, value as
>>Array);
>> +                comp.setStyle(name, value);
>> +            }
>> +
>> +            m = data[i++]; // num events
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                value = data[i++];
>> +                comp.addEventListener(name, value);
>> +            }
>> +
>> +            var children:Array = data[i++];
>> +            if (children)
>> +            {
>> +                if (recursive)
>> +                    comp.generateMXMLInstances(document, children,
>>recursive);
>> +                else
>> +                    comp.setMXMLDescriptor(children);
>> +            }
>> +
>> +            if (id)
>> +            {
>> +                document[id] = comp;
>> +                mx.binding.BindingManager.executeBindings(document,
>>id, comp);
>> +            }
>> +            if (comp is IMXMLObject)
>> +                comp.initialized(document, id);
>> +            comps.push(comp);
>> +        }
>> +        return comps;
>> +    }
>> +
>> +    protected function generateMXMLInstances(document:Object,
>>data:Array, recursive:Boolean = true):void
>> +    {
>> +        var comps:Array = generateMXMLArray(document, data, recursive);
>> +        addMXMLChildren(comps);
>> +    }
>> +
>> +    protected function generateMXMLAttributes(data:Array):void
>> +    {
>> +        var i:int = 0;
>> +        var m:int;
>> +        var j:int;
>> +        var name:String;
>> +        var simple:*;
>> +        var value:Object;
>> +        var id:String = null;
>> +
>> +        m = data[i++]; // num props
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            simple = data[i++];
>> +            value = data[i++];
>> +            if (simple == null)
>> +                value = generateMXMLArray(this, value as Array, false);
>> +            else if (simple == false)
>> +                value = generateMXMLObject(this, value as Array);
>> +            if (name == "id")
>> +                id = value as String;
>> +            if (name == "_id")
>> +                id = value as String; // and don't assign
>> +            else
>> +                this[name] = value;
>> +        }
>> +        m = data[i++]; // num styles
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            simple = data[i++];
>> +            value = data[i++];
>> +            if (simple == null)
>> +                value = generateMXMLArray(this, value as Array, false);
>> +            else if (simple == false)
>> +                value = generateMXMLObject(this, value as Array);
>> +            this.setStyle(name, value);
>> +        }
>> +
>> +        m = data[i++]; // num effects
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            simple = data[i++];
>> +            value = data[i++];
>> +            if (simple == null)
>> +                value = generateMXMLArray(this, value as Array, false);
>> +            else if (simple == false)
>> +                value = generateMXMLObject(this, value as Array);
>> +            this.setStyle(name, value);
>> +        }
>> +
>> +        m = data[i++]; // num events
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            value = data[i++];
>> +            this.addEventListener(name, value as Function);
>> +        }
>>      }
>> -
>>      /**
>>       *  Performs any final processing after child objects are created.
>>       *  This is an advanced method that you might override
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/framework/src/mx/states/AddItems.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/framework/src/mx/states/AddItems.as
>>b/frameworks/projects/framework/src/mx/states/AddItems.as
>> index 6fc388c..01fe514 100644
>> --- a/frameworks/projects/framework/src/mx/states/AddItems.as
>> +++ b/frameworks/projects/framework/src/mx/states/AddItems.as
>> @@ -26,10 +26,12 @@ import mx.collections.IList;
>>  import mx.core.ContainerCreationPolicy;
>>  import mx.core.IChildList;
>>  import mx.core.IDeferredContentOwner;
>> +import mx.core.IMXMLObject;
>>  import mx.core.ITransientDeferredInstance;
>>  import mx.core.IVisualElement;
>>  import mx.core.IVisualElementContainer;
>>  import mx.core.UIComponent;
>> +import mx.binding.BindingManager;
>>
>>  [DefaultProperty("itemsFactory")]
>>
>> @@ -41,7 +43,7 @@ import mx.core.UIComponent;
>>   *  @playerversion AIR 1.5
>>   *  @productversion Flex 4
>>   */
>> -public class AddItems extends OverrideBase
>> +public class AddItems extends OverrideBase implements IMXMLObject
>>  {
>>      include "../core/Version.as";
>>
>> @@ -115,7 +117,9 @@ public class AddItems extends OverrideBase
>>      //  Variables
>>      //
>>
>>//-----------------------------------------------------------------------
>>---
>> -
>> +
>> +    private var document:Object;
>> +
>>      /**
>>       *  @private
>>       */
>> @@ -308,6 +312,52 @@ public class AddItems extends OverrideBase
>>      {
>>          _items = value;
>>      }
>> +
>> +    //------------------------------------
>> +    //  itemsDescriptor
>> +    //------------------------------------
>> +
>> +    /**
>> +     *  @private
>> +     *  Storage for the itemsDescriptor property.
>> +     */
>> +    private var _itemsDescriptor:Array;
>> +
>> +    [Inspectable(category="General")]
>> +
>> +    /**
>> +     *
>> +     * The descriptor that describes the items.
>> +     *
>> +     *  <p>If you set this property, the items are instantiated at the
>>time
>> +     *  determined by the <code>creationPolicy</code> property.</p>
>> +     *
>> +     *  <p>Do not set this property if you set the <code>items</code>
>> +     *  property.
>> +     *  This propety is the <code>AddItems</code> class default
>>property.
>> +     *  Setting this property with a <code>creationPolicy</code> of
>>"all"
>> +     *  is equivalent to setting a <code>items</code> property.</p>
>> +     *
>> +     *  @langversion 3.0
>> +     *  @playerversion Flash 10
>> +     *  @playerversion AIR 1.5
>> +     *  @productversion Flex 4
>> +     */
>> +    public function get itemsDescriptor():Array
>> +    {
>> +        return _itemsDescriptor;
>> +    }
>> +
>> +    /**
>> +     *  @private
>> +     */
>> +    public function set itemsDescriptor(value:Array):void
>> +    {
>> +        _itemsDescriptor = value;
>> +
>> +        if (creationPolicy == ContainerCreationPolicy.ALL)
>> +            createInstance();
>> +    }
>>
>>      //------------------------------------
>>      //  itemsFactory
>> @@ -489,11 +539,132 @@ public class AddItems extends OverrideBase
>>       */
>>      public function createInstance():void
>>      {
>> -        if (!instanceCreated && !_items && itemsFactory)
>> +        if (!instanceCreated && !_items && itemsFactory &&
>>!_itemsDescriptor)
>>          {
>>              instanceCreated = true;
>>              items = itemsFactory.getInstance();
>>          }
>> +        else if (!instanceCreated && !_items && !itemsFactory &&
>>_itemsDescriptor)
>> +        {
>> +            instanceCreated = true;
>> +            items = generateMXMLArray(itemsDescriptor, false);
>> +        }
>> +    }
>> +
>> +    protected function generateMXMLObject(data:Array):Object
>> +    {
>> +        var i:int = 0;
>> +        var cls:Class = data[i++];
>> +        var comp:Object = new cls();
>> +
>> +        var m:int;
>> +        var j:int;
>> +        var name:String;
>> +        var simple:*;
>> +        var value:Object;
>> +        var id:String;
>> +
>> +        m = data[i++]; // num props
>> +        for (j = 0; j < m; j++)
>> +        {
>> +            name = data[i++];
>> +            simple = data[i++];
>> +            value = data[i++];
>> +            if (simple == null)
>> +                value = generateMXMLArray(value as Array);
>> +            else if (simple == false)
>> +                value = generateMXMLObject(value as Array);
>> +            comp[name] = value;
>> +        }
>> +        return comp;
>> +    }
>> +
>> +    // varies slightly from version in UIComponent in how it handles
>>documents
>> +    public function generateMXMLArray(data:Array, recursive:Boolean =
>>true):Array
>> +    {
>> +        var comps:Array = [];
>> +
>> +        var n:int = data.length;
>> +        var i:int = 0;
>> +        while (i < n)
>> +        {
>> +            var cls:Class = data[i++];
>> +            var comp:Object = new cls();
>> +
>> +            var m:int;
>> +            var j:int;
>> +            var name:String;
>> +            var simple:*;
>> +            var value:Object;
>> +            var id:String = null;
>> +
>> +            m = data[i++]; // num props
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(value as Array,
>>recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(value as Array);
>> +                if (name == "id")
>> +                    id = value as String;
>> +                if (name == "_id")
>> +                    id = value as String; // and don't assign to comp
>> +                else
>> +                    comp[name] = value;
>> +            }
>> +            m = data[i++]; // num styles
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(value as Array,
>>recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(value as Array);
>> +                comp.setStyle(name, value);
>> +            }
>> +
>> +            m = data[i++]; // num effects
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                simple = data[i++];
>> +                value = data[i++];
>> +                if (simple == null)
>> +                    value = generateMXMLArray(value as Array,
>>recursive);
>> +                else if (simple == false)
>> +                    value = generateMXMLObject(value as Array);
>> +                comp.setStyle(name, value);
>> +            }
>> +
>> +            m = data[i++]; // num events
>> +            for (j = 0; j < m; j++)
>> +            {
>> +                name = data[i++];
>> +                value = data[i++];
>> +                comp.addEventListener(name, value);
>> +            }
>> +
>> +            var children:Array = data[i++];
>> +            if (children)
>> +            {
>> +                if (recursive)
>> +                    comp.generateMXMLInstances(children, recursive);
>> +                else
>> +                    comp.setMXMLDescriptor(children);
>> +            }
>> +            if (id)
>> +            {
>> +                document[id] = comp;
>> +                mx.binding.BindingManager.executeBindings(document,
>>id, comp);
>> +            }
>> +            comps.push(comp);
>> +        }
>> +        return comps;
>>      }
>>
>>      /**
>> @@ -907,6 +1078,15 @@ public class AddItems extends OverrideBase
>>              _waitingForDeferredContent = false;
>>          }
>>      }
>> +
>> +    /**
>> +     *  IMXMLObject support
>> +     */
>> +    public function initialized(document:Object, id:String):void
>> +    {
>> +        this.document = document;
>> +    }
>> +
>>  }
>>
>>  }
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/mx/src/mx/containers/ViewStack.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/mx/src/mx/containers/ViewStack.as
>>b/frameworks/projects/mx/src/mx/containers/ViewStack.as
>> index e2b97d5..bf462ca 100644
>> --- a/frameworks/projects/mx/src/mx/containers/ViewStack.as
>> +++ b/frameworks/projects/mx/src/mx/containers/ViewStack.as
>> @@ -738,6 +738,15 @@ public class ViewStack extends Container
>>implements IHistoryManagerClient, ISele
>>
>>      /**
>>       *  @private
>> +     */
>> +    override protected function generateMXMLInstances(document:Object,
>>data:Array, recursive:Boolean = true):void
>> +    {
>> +        // in theory, creationpolicy gets applied later
>> +        super.generateMXMLInstances(document, data, false);
>> +    }
>> +
>> +    /**
>> +     *  @private
>>       */
>>      override protected function commitProperties():void
>>      {
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/mx/src/mx/core/Container.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/mx/src/mx/core/Container.as
>>b/frameworks/projects/mx/src/mx/core/Container.as
>> index 635d8bc..c3f7d91 100644
>> --- a/frameworks/projects/mx/src/mx/core/Container.as
>> +++ b/frameworks/projects/mx/src/mx/core/Container.as
>> @@ -4219,7 +4219,11 @@ public class Container extends UIComponent
>>       */
>>      public function createDeferredContent():void
>>      {
>> -        createComponentsFromDescriptors(true);
>> +        var children:Array =  this.MXMLDescriptor;
>> +        if (children)
>> +            generateMXMLInstances(document, children);
>> +        else
>> +            createComponentsFromDescriptors(true);
>>      }
>>
>>     /**
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/spark/src/spark/components/Group.as
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/spark/src/spark/components/Group.as
>>b/frameworks/projects/spark/src/spark/components/Group.as
>> index 7068fc5..f3a75fb 100644
>> --- a/frameworks/projects/spark/src/spark/components/Group.as
>> +++ b/frameworks/projects/spark/src/spark/components/Group.as
>> @@ -546,7 +546,15 @@ public class Group extends GroupBase implements
>>IVisualElementContainer,
>>
>>          }
>>      }
>> -
>> +
>> +    /**
>> +     *  override setting of children
>> +     */
>> +    override protected function addMXMLChildren(comps:Array):void
>> +    {
>> +        mxmlContent = comps;
>> +    }
>> +
>>      //----------------------------------
>>      //  mxmlContent
>>      //----------------------------------
>>
>>
>>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/
>>projects/spark/src/spark/components/SkinnableContainer.as
>> ----------------------------------------------------------------------
>> diff --git
>>a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
>>b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
>> index f011a01..edff9c6 100644
>> ---
>>a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
>> +++
>>b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
>> @@ -672,6 +672,14 @@ public class SkinnableContainer extends
>>SkinnableContainerBase
>>              _contentModified = true;
>>      }
>>
>> +    /**
>> +     *  override setting of children
>> +     */
>> +    override protected function addMXMLChildren(comps:Array):void
>> +    {
>> +        mxmlContent = comps;
>> +    }
>> +
>>      //----------------------------------
>>      //  mxmlContentFactory
>>      //----------------------------------
>> @@ -873,6 +881,17 @@ public class SkinnableContainer extends
>>SkinnableContainerBase
>>      //
>>
>>//-----------------------------------------------------------------------
>>---
>>
>> +    private var creatingChildren:Boolean;
>> +
>> +    override protected function generateMXMLInstances(document:Object,
>>data:Array, recursive:Boolean = true):void
>> +    {
>> +        // don't generate children during super.createChildren
>> +        if (creatingChildren)
>> +            return;
>> +
>> +        super.generateMXMLInstances(document, data, recursive);
>> +    }
>> +
>>      /**
>>       *  Create content children, if the <code>creationPolicy</code>
>>property
>>       *  is not equal to <code>none</code>.
>> @@ -884,7 +903,9 @@ public class SkinnableContainer extends
>>SkinnableContainerBase
>>       */
>>      override protected function createChildren():void
>>      {
>> +        creatingChildren = true;
>>          super.createChildren();
>> +        creatingChildren = false;
>>
>>          // TODO (rfrishbe): When navigator support is added, this is
>>where we would
>>          // determine if content should be created now, or wait until
>> @@ -1048,6 +1069,16 @@ public class SkinnableContainer extends
>>SkinnableContainerBase
>>       */
>>      public function createDeferredContent():void
>>      {
>> +        var children:Array =  this.MXMLDescriptor;
>> +        if (children)
>> +        {
>> +            generateMXMLInstances(document, children);
>> +            mxmlContentCreated = true; // keep the code from recursing
>>back into here.
>> +            _deferredContentCreated = true;
>> +            dispatchEvent(new
>>FlexEvent(FlexEvent.CONTENT_CREATION_COMPLETE));
>> +            return;
>> +        }
>> +
>>          if (!mxmlContentCreated)
>>          {
>>              mxmlContentCreated = true;
>>
>
>
>
>--
>Ix Multimedia Software
>
>Jan Luykenstraat 27
>3521 VB Utrecht
>
>T. 06-51952295
>I. www.ixsoftware.nl


Re: [2/2] git commit: [flex-sdk] [refs/heads/develop] - support mxml.children-as-data mainstream SDK

Posted by Erik de Bruin <er...@ixsoftware.nl>.
Daring move... what are you trying to achieve? Are you attempting to
get some kind of "vanilla SDK" support going for FlexJS?

EdB



On Sat, Jul 6, 2013 at 8:29 AM,  <ah...@apache.org> wrote:
> support mxml.children-as-data mainstream SDK
>
>
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/6907ac09
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/6907ac09
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/6907ac09
>
> Branch: refs/heads/develop
> Commit: 6907ac09e43f1df07af558964946316dddefd829
> Parents: aeed464
> Author: Alex Harui <ah...@apache.org>
> Authored: Thu Jun 27 23:34:51 2013 -0700
> Committer: Alex Harui <ah...@apache.org>
> Committed: Fri Jul 5 23:29:02 2013 -0700
>
> ----------------------------------------------------------------------
>  .../framework/src/mx/core/UIComponent.as        | 256 ++++++++++++++++++-
>  .../framework/src/mx/states/AddItems.as         | 186 +++++++++++++-
>  .../projects/mx/src/mx/containers/ViewStack.as  |   9 +
>  frameworks/projects/mx/src/mx/core/Container.as |   6 +-
>  .../spark/src/spark/components/Group.as         |  10 +-
>  .../src/spark/components/SkinnableContainer.as  |  31 +++
>  6 files changed, 492 insertions(+), 6 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/framework/src/mx/core/UIComponent.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/framework/src/mx/core/UIComponent.as b/frameworks/projects/framework/src/mx/core/UIComponent.as
> index 8e46058..4eb4a6f 100644
> --- a/frameworks/projects/framework/src/mx/core/UIComponent.as
> +++ b/frameworks/projects/framework/src/mx/core/UIComponent.as
> @@ -1723,6 +1723,11 @@ public class UIComponent extends FlexSprite
>
>          _width = super.width;
>          _height = super.height;
> +
> +        var attributes:Array =  this.MXMLProperties;
> +        if (attributes)
> +            generateMXMLAttributes(attributes);
> +
>      }
>
>      //--------------------------------------------------------------------------
> @@ -4425,6 +4430,44 @@ public class UIComponent extends FlexSprite
>      {
>          return document == this;
>      }
> +
> +    //----------------------------------
> +    //  MXML Descriptor
> +    //----------------------------------
> +
> +    /**
> +     *  The descriptor of MXML children.
> +     */
> +    private var _MXMLDescriptor:Array;
> +
> +    public function get MXMLDescriptor():Array
> +    {
> +        return _MXMLDescriptor;
> +    }
> +
> +    public function setMXMLDescriptor(value:Array):void
> +    {
> +        _MXMLDescriptor = value;
> +    }
> +
> +    //----------------------------------
> +    //  MXML Properties
> +    //----------------------------------
> +
> +    /**
> +     *  The attributes of MXML top tag.
> +     */
> +    private var _MXMLProperties:Array;
> +
> +    public function get MXMLProperties():Array
> +    {
> +        return _MXMLProperties;
> +    }
> +
> +    public function setMXMLProperties(value:Array):void
> +    {
> +        _MXMLProperties = value;
> +    }
>
>      //----------------------------------
>      //  parentApplication
> @@ -7763,8 +7806,219 @@ public class UIComponent extends FlexSprite
>       */
>      protected function createChildren():void
>      {
> +        var children:Array =  this.MXMLDescriptor;
> +        if (children)
> +            generateMXMLInstances(document, children);
> +    }
> +
> +    protected function addMXMLChildren(comps:Array):void
> +    {
> +        for each (var i:DisplayObject in comps)
> +        {
> +            addChild(i);
> +        }
> +    }
> +
> +    protected function generateMXMLObject(document:Object, data:Array):Object
> +    {
> +        var i:int = 0;
> +        var cls:Class = data[i++];
> +        var comp:Object = new cls();
> +
> +        var m:int;
> +        var j:int;
> +        var name:String;
> +        var simple:*;
> +        var value:Object;
> +        var id:String;
> +
> +        m = data[i++]; // num props
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            simple = data[i++];
> +            value = data[i++];
> +            if (simple == null)
> +                value = generateMXMLArray(document, value as Array);
> +            else if (simple == false)
> +                value = generateMXMLObject(document, value as Array);
> +            if (name == "id")
> +            {
> +                document[value] = comp;
> +                id = value as String;
> +            }
> +            else if (name == "_id")
> +            {
> +                document[value] = comp;
> +                id = value as String;
> +                continue; // skip assignment to comp
> +            }
> +            comp[name] = value;
> +        }
> +        if (comp is IMXMLObject)
> +            comp.initialized(document, id);
> +        return comp;
> +    }
> +
> +    public function generateMXMLArray(document:Object, data:Array, recursive:Boolean = true):Array
> +    {
> +        var comps:Array = [];
> +
> +        var n:int = data.length;
> +        var i:int = 0;
> +        while (i < n)
> +        {
> +            var cls:Class = data[i++];
> +            var comp:Object = new cls();
> +
> +            var m:int;
> +            var j:int;
> +            var name:String;
> +            var simple:*;
> +            var value:Object;
> +            var id:String = null;
> +
> +            m = data[i++]; // num props
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(document, value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(document, value as Array);
> +                if (name == "id")
> +                    id = value as String;
> +                if (name == "document" && !comp.document)
> +                    comp.document = document;
> +                else if (name == "_id")
> +                    id = value as String; // and don't assign to comp
> +                else
> +                    comp[name] = value;
> +            }
> +            m = data[i++]; // num styles
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(document, value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(document, value as Array);
> +                comp.setStyle(name, value);
> +            }
> +
> +            m = data[i++]; // num effects
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(document, value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(document, value as Array);
> +                comp.setStyle(name, value);
> +            }
> +
> +            m = data[i++]; // num events
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                value = data[i++];
> +                comp.addEventListener(name, value);
> +            }
> +
> +            var children:Array = data[i++];
> +            if (children)
> +            {
> +                if (recursive)
> +                    comp.generateMXMLInstances(document, children, recursive);
> +                else
> +                    comp.setMXMLDescriptor(children);
> +            }
> +
> +            if (id)
> +            {
> +                document[id] = comp;
> +                mx.binding.BindingManager.executeBindings(document, id, comp);
> +            }
> +            if (comp is IMXMLObject)
> +                comp.initialized(document, id);
> +            comps.push(comp);
> +        }
> +        return comps;
> +    }
> +
> +    protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
> +    {
> +        var comps:Array = generateMXMLArray(document, data, recursive);
> +        addMXMLChildren(comps);
> +    }
> +
> +    protected function generateMXMLAttributes(data:Array):void
> +    {
> +        var i:int = 0;
> +        var m:int;
> +        var j:int;
> +        var name:String;
> +        var simple:*;
> +        var value:Object;
> +        var id:String = null;
> +
> +        m = data[i++]; // num props
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            simple = data[i++];
> +            value = data[i++];
> +            if (simple == null)
> +                value = generateMXMLArray(this, value as Array, false);
> +            else if (simple == false)
> +                value = generateMXMLObject(this, value as Array);
> +            if (name == "id")
> +                id = value as String;
> +            if (name == "_id")
> +                id = value as String; // and don't assign
> +            else
> +                this[name] = value;
> +        }
> +        m = data[i++]; // num styles
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            simple = data[i++];
> +            value = data[i++];
> +            if (simple == null)
> +                value = generateMXMLArray(this, value as Array, false);
> +            else if (simple == false)
> +                value = generateMXMLObject(this, value as Array);
> +            this.setStyle(name, value);
> +        }
> +
> +        m = data[i++]; // num effects
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            simple = data[i++];
> +            value = data[i++];
> +            if (simple == null)
> +                value = generateMXMLArray(this, value as Array, false);
> +            else if (simple == false)
> +                value = generateMXMLObject(this, value as Array);
> +            this.setStyle(name, value);
> +        }
> +
> +        m = data[i++]; // num events
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            value = data[i++];
> +            this.addEventListener(name, value as Function);
> +        }
>      }
> -
>      /**
>       *  Performs any final processing after child objects are created.
>       *  This is an advanced method that you might override
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/framework/src/mx/states/AddItems.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/framework/src/mx/states/AddItems.as b/frameworks/projects/framework/src/mx/states/AddItems.as
> index 6fc388c..01fe514 100644
> --- a/frameworks/projects/framework/src/mx/states/AddItems.as
> +++ b/frameworks/projects/framework/src/mx/states/AddItems.as
> @@ -26,10 +26,12 @@ import mx.collections.IList;
>  import mx.core.ContainerCreationPolicy;
>  import mx.core.IChildList;
>  import mx.core.IDeferredContentOwner;
> +import mx.core.IMXMLObject;
>  import mx.core.ITransientDeferredInstance;
>  import mx.core.IVisualElement;
>  import mx.core.IVisualElementContainer;
>  import mx.core.UIComponent;
> +import mx.binding.BindingManager;
>
>  [DefaultProperty("itemsFactory")]
>
> @@ -41,7 +43,7 @@ import mx.core.UIComponent;
>   *  @playerversion AIR 1.5
>   *  @productversion Flex 4
>   */
> -public class AddItems extends OverrideBase
> +public class AddItems extends OverrideBase implements IMXMLObject
>  {
>      include "../core/Version.as";
>
> @@ -115,7 +117,9 @@ public class AddItems extends OverrideBase
>      //  Variables
>      //
>      //--------------------------------------------------------------------------
> -
> +
> +    private var document:Object;
> +
>      /**
>       *  @private
>       */
> @@ -308,6 +312,52 @@ public class AddItems extends OverrideBase
>      {
>          _items = value;
>      }
> +
> +    //------------------------------------
> +    //  itemsDescriptor
> +    //------------------------------------
> +
> +    /**
> +     *  @private
> +     *  Storage for the itemsDescriptor property.
> +     */
> +    private var _itemsDescriptor:Array;
> +
> +    [Inspectable(category="General")]
> +
> +    /**
> +     *
> +     * The descriptor that describes the items.
> +     *
> +     *  <p>If you set this property, the items are instantiated at the time
> +     *  determined by the <code>creationPolicy</code> property.</p>
> +     *
> +     *  <p>Do not set this property if you set the <code>items</code>
> +     *  property.
> +     *  This propety is the <code>AddItems</code> class default property.
> +     *  Setting this property with a <code>creationPolicy</code> of "all"
> +     *  is equivalent to setting a <code>items</code> property.</p>
> +     *
> +     *  @langversion 3.0
> +     *  @playerversion Flash 10
> +     *  @playerversion AIR 1.5
> +     *  @productversion Flex 4
> +     */
> +    public function get itemsDescriptor():Array
> +    {
> +        return _itemsDescriptor;
> +    }
> +
> +    /**
> +     *  @private
> +     */
> +    public function set itemsDescriptor(value:Array):void
> +    {
> +        _itemsDescriptor = value;
> +
> +        if (creationPolicy == ContainerCreationPolicy.ALL)
> +            createInstance();
> +    }
>
>      //------------------------------------
>      //  itemsFactory
> @@ -489,11 +539,132 @@ public class AddItems extends OverrideBase
>       */
>      public function createInstance():void
>      {
> -        if (!instanceCreated && !_items && itemsFactory)
> +        if (!instanceCreated && !_items && itemsFactory && !_itemsDescriptor)
>          {
>              instanceCreated = true;
>              items = itemsFactory.getInstance();
>          }
> +        else if (!instanceCreated && !_items && !itemsFactory && _itemsDescriptor)
> +        {
> +            instanceCreated = true;
> +            items = generateMXMLArray(itemsDescriptor, false);
> +        }
> +    }
> +
> +    protected function generateMXMLObject(data:Array):Object
> +    {
> +        var i:int = 0;
> +        var cls:Class = data[i++];
> +        var comp:Object = new cls();
> +
> +        var m:int;
> +        var j:int;
> +        var name:String;
> +        var simple:*;
> +        var value:Object;
> +        var id:String;
> +
> +        m = data[i++]; // num props
> +        for (j = 0; j < m; j++)
> +        {
> +            name = data[i++];
> +            simple = data[i++];
> +            value = data[i++];
> +            if (simple == null)
> +                value = generateMXMLArray(value as Array);
> +            else if (simple == false)
> +                value = generateMXMLObject(value as Array);
> +            comp[name] = value;
> +        }
> +        return comp;
> +    }
> +
> +    // varies slightly from version in UIComponent in how it handles documents
> +    public function generateMXMLArray(data:Array, recursive:Boolean = true):Array
> +    {
> +        var comps:Array = [];
> +
> +        var n:int = data.length;
> +        var i:int = 0;
> +        while (i < n)
> +        {
> +            var cls:Class = data[i++];
> +            var comp:Object = new cls();
> +
> +            var m:int;
> +            var j:int;
> +            var name:String;
> +            var simple:*;
> +            var value:Object;
> +            var id:String = null;
> +
> +            m = data[i++]; // num props
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(value as Array);
> +                if (name == "id")
> +                    id = value as String;
> +                if (name == "_id")
> +                    id = value as String; // and don't assign to comp
> +                else
> +                    comp[name] = value;
> +            }
> +            m = data[i++]; // num styles
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(value as Array);
> +                comp.setStyle(name, value);
> +            }
> +
> +            m = data[i++]; // num effects
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                simple = data[i++];
> +                value = data[i++];
> +                if (simple == null)
> +                    value = generateMXMLArray(value as Array, recursive);
> +                else if (simple == false)
> +                    value = generateMXMLObject(value as Array);
> +                comp.setStyle(name, value);
> +            }
> +
> +            m = data[i++]; // num events
> +            for (j = 0; j < m; j++)
> +            {
> +                name = data[i++];
> +                value = data[i++];
> +                comp.addEventListener(name, value);
> +            }
> +
> +            var children:Array = data[i++];
> +            if (children)
> +            {
> +                if (recursive)
> +                    comp.generateMXMLInstances(children, recursive);
> +                else
> +                    comp.setMXMLDescriptor(children);
> +            }
> +            if (id)
> +            {
> +                document[id] = comp;
> +                mx.binding.BindingManager.executeBindings(document, id, comp);
> +            }
> +            comps.push(comp);
> +        }
> +        return comps;
>      }
>
>      /**
> @@ -907,6 +1078,15 @@ public class AddItems extends OverrideBase
>              _waitingForDeferredContent = false;
>          }
>      }
> +
> +    /**
> +     *  IMXMLObject support
> +     */
> +    public function initialized(document:Object, id:String):void
> +    {
> +        this.document = document;
> +    }
> +
>  }
>
>  }
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/mx/src/mx/containers/ViewStack.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/mx/src/mx/containers/ViewStack.as b/frameworks/projects/mx/src/mx/containers/ViewStack.as
> index e2b97d5..bf462ca 100644
> --- a/frameworks/projects/mx/src/mx/containers/ViewStack.as
> +++ b/frameworks/projects/mx/src/mx/containers/ViewStack.as
> @@ -738,6 +738,15 @@ public class ViewStack extends Container implements IHistoryManagerClient, ISele
>
>      /**
>       *  @private
> +     */
> +    override protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
> +    {
> +        // in theory, creationpolicy gets applied later
> +        super.generateMXMLInstances(document, data, false);
> +    }
> +
> +    /**
> +     *  @private
>       */
>      override protected function commitProperties():void
>      {
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/mx/src/mx/core/Container.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/mx/src/mx/core/Container.as b/frameworks/projects/mx/src/mx/core/Container.as
> index 635d8bc..c3f7d91 100644
> --- a/frameworks/projects/mx/src/mx/core/Container.as
> +++ b/frameworks/projects/mx/src/mx/core/Container.as
> @@ -4219,7 +4219,11 @@ public class Container extends UIComponent
>       */
>      public function createDeferredContent():void
>      {
> -        createComponentsFromDescriptors(true);
> +        var children:Array =  this.MXMLDescriptor;
> +        if (children)
> +            generateMXMLInstances(document, children);
> +        else
> +            createComponentsFromDescriptors(true);
>      }
>
>     /**
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/spark/src/spark/components/Group.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/spark/src/spark/components/Group.as b/frameworks/projects/spark/src/spark/components/Group.as
> index 7068fc5..f3a75fb 100644
> --- a/frameworks/projects/spark/src/spark/components/Group.as
> +++ b/frameworks/projects/spark/src/spark/components/Group.as
> @@ -546,7 +546,15 @@ public class Group extends GroupBase implements IVisualElementContainer,
>
>          }
>      }
> -
> +
> +    /**
> +     *  override setting of children
> +     */
> +    override protected function addMXMLChildren(comps:Array):void
> +    {
> +        mxmlContent = comps;
> +    }
> +
>      //----------------------------------
>      //  mxmlContent
>      //----------------------------------
>
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
> index f011a01..edff9c6 100644
> --- a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
> +++ b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
> @@ -672,6 +672,14 @@ public class SkinnableContainer extends SkinnableContainerBase
>              _contentModified = true;
>      }
>
> +    /**
> +     *  override setting of children
> +     */
> +    override protected function addMXMLChildren(comps:Array):void
> +    {
> +        mxmlContent = comps;
> +    }
> +
>      //----------------------------------
>      //  mxmlContentFactory
>      //----------------------------------
> @@ -873,6 +881,17 @@ public class SkinnableContainer extends SkinnableContainerBase
>      //
>      //--------------------------------------------------------------------------
>
> +    private var creatingChildren:Boolean;
> +
> +    override protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
> +    {
> +        // don't generate children during super.createChildren
> +        if (creatingChildren)
> +            return;
> +
> +        super.generateMXMLInstances(document, data, recursive);
> +    }
> +
>      /**
>       *  Create content children, if the <code>creationPolicy</code> property
>       *  is not equal to <code>none</code>.
> @@ -884,7 +903,9 @@ public class SkinnableContainer extends SkinnableContainerBase
>       */
>      override protected function createChildren():void
>      {
> +        creatingChildren = true;
>          super.createChildren();
> +        creatingChildren = false;
>
>          // TODO (rfrishbe): When navigator support is added, this is where we would
>          // determine if content should be created now, or wait until
> @@ -1048,6 +1069,16 @@ public class SkinnableContainer extends SkinnableContainerBase
>       */
>      public function createDeferredContent():void
>      {
> +        var children:Array =  this.MXMLDescriptor;
> +        if (children)
> +        {
> +            generateMXMLInstances(document, children);
> +            mxmlContentCreated = true; // keep the code from recursing back into here.
> +            _deferredContentCreated = true;
> +            dispatchEvent(new FlexEvent(FlexEvent.CONTENT_CREATION_COMPLETE));
> +            return;
> +        }
> +
>          if (!mxmlContentCreated)
>          {
>              mxmlContentCreated = true;
>



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

[2/2] git commit: [flex-sdk] [refs/heads/develop] - support mxml.children-as-data mainstream SDK

Posted by ah...@apache.org.
support mxml.children-as-data mainstream SDK


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/6907ac09
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/6907ac09
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/6907ac09

Branch: refs/heads/develop
Commit: 6907ac09e43f1df07af558964946316dddefd829
Parents: aeed464
Author: Alex Harui <ah...@apache.org>
Authored: Thu Jun 27 23:34:51 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Fri Jul 5 23:29:02 2013 -0700

----------------------------------------------------------------------
 .../framework/src/mx/core/UIComponent.as        | 256 ++++++++++++++++++-
 .../framework/src/mx/states/AddItems.as         | 186 +++++++++++++-
 .../projects/mx/src/mx/containers/ViewStack.as  |   9 +
 frameworks/projects/mx/src/mx/core/Container.as |   6 +-
 .../spark/src/spark/components/Group.as         |  10 +-
 .../src/spark/components/SkinnableContainer.as  |  31 +++
 6 files changed, 492 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/framework/src/mx/core/UIComponent.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/core/UIComponent.as b/frameworks/projects/framework/src/mx/core/UIComponent.as
index 8e46058..4eb4a6f 100644
--- a/frameworks/projects/framework/src/mx/core/UIComponent.as
+++ b/frameworks/projects/framework/src/mx/core/UIComponent.as
@@ -1723,6 +1723,11 @@ public class UIComponent extends FlexSprite
 
         _width = super.width;
         _height = super.height;
+        
+        var attributes:Array =  this.MXMLProperties;
+        if (attributes)
+            generateMXMLAttributes(attributes);
+
     }
 
     //--------------------------------------------------------------------------
@@ -4425,6 +4430,44 @@ public class UIComponent extends FlexSprite
     {
         return document == this;
     }
+    
+    //----------------------------------
+    //  MXML Descriptor
+    //----------------------------------
+    
+    /**
+     *  The descriptor of MXML children.
+     */
+    private var _MXMLDescriptor:Array;
+    
+    public function get MXMLDescriptor():Array
+    {
+        return _MXMLDescriptor;
+    }
+    
+    public function setMXMLDescriptor(value:Array):void
+    {
+        _MXMLDescriptor = value;    
+    }
+    
+    //----------------------------------
+    //  MXML Properties
+    //----------------------------------
+    
+    /**
+     *  The attributes of MXML top tag.
+     */
+    private var _MXMLProperties:Array;
+    
+    public function get MXMLProperties():Array
+    {
+        return _MXMLProperties;
+    }
+    
+    public function setMXMLProperties(value:Array):void
+    {
+        _MXMLProperties = value;    
+    }
 
     //----------------------------------
     //  parentApplication
@@ -7763,8 +7806,219 @@ public class UIComponent extends FlexSprite
      */
     protected function createChildren():void
     {
+        var children:Array =  this.MXMLDescriptor;
+        if (children)
+            generateMXMLInstances(document, children);
+    }
+    
+    protected function addMXMLChildren(comps:Array):void
+    {
+        for each (var i:DisplayObject in comps)
+        {
+            addChild(i);
+        }
+    }
+    
+    protected function generateMXMLObject(document:Object, data:Array):Object
+    {
+        var i:int = 0;
+        var cls:Class = data[i++];
+        var comp:Object = new cls();
+        
+        var m:int;
+        var j:int;
+        var name:String;
+        var simple:*;
+        var value:Object;
+        var id:String;
+        
+        m = data[i++]; // num props
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            simple = data[i++];
+            value = data[i++];
+            if (simple == null)
+                value = generateMXMLArray(document, value as Array);
+            else if (simple == false)
+                value = generateMXMLObject(document, value as Array);
+            if (name == "id")
+            {
+                document[value] = comp;
+                id = value as String;
+            }
+            else if (name == "_id")
+            {
+                document[value] = comp;
+                id = value as String;
+                continue; // skip assignment to comp
+            }
+            comp[name] = value;
+        }
+        if (comp is IMXMLObject)
+            comp.initialized(document, id);
+        return comp;
+    }
+    
+    public function generateMXMLArray(document:Object, data:Array, recursive:Boolean = true):Array
+    {
+        var comps:Array = [];
+        
+        var n:int = data.length;
+        var i:int = 0;
+        while (i < n)
+        {
+            var cls:Class = data[i++];
+            var comp:Object = new cls();
+            
+            var m:int;
+            var j:int;
+            var name:String;
+            var simple:*;
+            var value:Object;
+            var id:String = null;
+            
+            m = data[i++]; // num props
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(document, value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(document, value as Array);
+                if (name == "id")
+                    id = value as String;
+                if (name == "document" && !comp.document)
+                    comp.document = document;
+                else if (name == "_id")
+                    id = value as String; // and don't assign to comp
+                else
+                    comp[name] = value;
+            }
+            m = data[i++]; // num styles
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(document, value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(document, value as Array);
+                comp.setStyle(name, value);
+            }
+            
+            m = data[i++]; // num effects
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(document, value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(document, value as Array);
+                comp.setStyle(name, value);
+            }
+            
+            m = data[i++]; // num events
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                value = data[i++];
+                comp.addEventListener(name, value);
+            }
+            
+            var children:Array = data[i++];
+            if (children)
+            {
+                if (recursive)
+                    comp.generateMXMLInstances(document, children, recursive);
+                else
+                    comp.setMXMLDescriptor(children);
+            }
+            
+            if (id)
+            {
+                document[id] = comp;
+                mx.binding.BindingManager.executeBindings(document, id, comp); 
+            }
+            if (comp is IMXMLObject)
+                comp.initialized(document, id);
+            comps.push(comp);
+        }
+        return comps;
+    }
+    
+    protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
+    {
+        var comps:Array = generateMXMLArray(document, data, recursive);
+        addMXMLChildren(comps);
+    }
+    
+    protected function generateMXMLAttributes(data:Array):void
+    {
+        var i:int = 0;
+        var m:int;
+        var j:int;
+        var name:String;
+        var simple:*;
+        var value:Object;
+        var id:String = null;
+        
+        m = data[i++]; // num props
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            simple = data[i++];
+            value = data[i++];
+            if (simple == null)
+                value = generateMXMLArray(this, value as Array, false);
+            else if (simple == false)
+                value = generateMXMLObject(this, value as Array);
+            if (name == "id")
+                id = value as String;
+            if (name == "_id")
+                id = value as String; // and don't assign
+            else
+                this[name] = value;
+        }
+        m = data[i++]; // num styles
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            simple = data[i++];
+            value = data[i++];
+            if (simple == null)
+                value = generateMXMLArray(this, value as Array, false);
+            else if (simple == false)
+                value = generateMXMLObject(this, value as Array);
+            this.setStyle(name, value);
+        }
+        
+        m = data[i++]; // num effects
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            simple = data[i++];
+            value = data[i++];
+            if (simple == null)
+                value = generateMXMLArray(this, value as Array, false);
+            else if (simple == false)
+                value = generateMXMLObject(this, value as Array);
+            this.setStyle(name, value);
+        }
+        
+        m = data[i++]; // num events
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            value = data[i++];
+            this.addEventListener(name, value as Function);
+        }
     }
-
     /**
      *  Performs any final processing after child objects are created.
      *  This is an advanced method that you might override

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/framework/src/mx/states/AddItems.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/states/AddItems.as b/frameworks/projects/framework/src/mx/states/AddItems.as
index 6fc388c..01fe514 100644
--- a/frameworks/projects/framework/src/mx/states/AddItems.as
+++ b/frameworks/projects/framework/src/mx/states/AddItems.as
@@ -26,10 +26,12 @@ import mx.collections.IList;
 import mx.core.ContainerCreationPolicy;
 import mx.core.IChildList;
 import mx.core.IDeferredContentOwner;
+import mx.core.IMXMLObject;
 import mx.core.ITransientDeferredInstance;
 import mx.core.IVisualElement;
 import mx.core.IVisualElementContainer;
 import mx.core.UIComponent;
+import mx.binding.BindingManager;
 
 [DefaultProperty("itemsFactory")]
 
@@ -41,7 +43,7 @@ import mx.core.UIComponent;
  *  @playerversion AIR 1.5
  *  @productversion Flex 4
  */
-public class AddItems extends OverrideBase 
+public class AddItems extends OverrideBase implements IMXMLObject 
 {
     include "../core/Version.as";
 
@@ -115,7 +117,9 @@ public class AddItems extends OverrideBase
     //  Variables
     //
     //--------------------------------------------------------------------------
-
+    
+    private var document:Object;	
+    
     /**
      *  @private
      */
@@ -308,6 +312,52 @@ public class AddItems extends OverrideBase
     {
         _items = value;
     }
+    
+    //------------------------------------
+    //  itemsDescriptor
+    //------------------------------------
+    
+    /**
+     *  @private
+     *  Storage for the itemsDescriptor property.
+     */
+    private var _itemsDescriptor:Array;
+    
+    [Inspectable(category="General")]
+    
+    /**
+     *
+     * The descriptor that describes the items. 
+     *
+     *  <p>If you set this property, the items are instantiated at the time
+     *  determined by the <code>creationPolicy</code> property.</p>
+     *  
+     *  <p>Do not set this property if you set the <code>items</code>
+     *  property.
+     *  This propety is the <code>AddItems</code> class default property.
+     *  Setting this property with a <code>creationPolicy</code> of "all"
+     *  is equivalent to setting a <code>items</code> property.</p>
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get itemsDescriptor():Array
+    {
+        return _itemsDescriptor;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set itemsDescriptor(value:Array):void
+    {
+        _itemsDescriptor = value;
+        
+        if (creationPolicy == ContainerCreationPolicy.ALL)
+            createInstance();
+    }
 
     //------------------------------------
     //  itemsFactory
@@ -489,11 +539,132 @@ public class AddItems extends OverrideBase
      */
     public function createInstance():void
     {
-        if (!instanceCreated && !_items && itemsFactory)
+        if (!instanceCreated && !_items && itemsFactory && !_itemsDescriptor)
         {
             instanceCreated = true;
             items = itemsFactory.getInstance();
         }
+        else if (!instanceCreated && !_items && !itemsFactory && _itemsDescriptor)
+        {
+            instanceCreated = true;
+            items = generateMXMLArray(itemsDescriptor, false);
+        }
+    }
+    
+    protected function generateMXMLObject(data:Array):Object
+    {
+        var i:int = 0;
+        var cls:Class = data[i++];
+        var comp:Object = new cls();
+        
+        var m:int;
+        var j:int;
+        var name:String;
+        var simple:*;
+        var value:Object;
+        var id:String;
+        
+        m = data[i++]; // num props
+        for (j = 0; j < m; j++)
+        {
+            name = data[i++];
+            simple = data[i++];
+            value = data[i++];
+            if (simple == null)
+                value = generateMXMLArray(value as Array);
+            else if (simple == false)
+                value = generateMXMLObject(value as Array);
+            comp[name] = value;
+        }
+        return comp;
+    }
+    
+    // varies slightly from version in UIComponent in how it handles documents
+    public function generateMXMLArray(data:Array, recursive:Boolean = true):Array
+    {
+        var comps:Array = [];
+        
+        var n:int = data.length;
+        var i:int = 0;
+        while (i < n)
+        {
+            var cls:Class = data[i++];
+            var comp:Object = new cls();
+            
+            var m:int;
+            var j:int;
+            var name:String;
+            var simple:*;
+            var value:Object;
+            var id:String = null;
+            
+            m = data[i++]; // num props
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(value as Array);
+                if (name == "id")
+                    id = value as String;
+                if (name == "_id")
+                    id = value as String; // and don't assign to comp
+                else
+                    comp[name] = value;
+            }
+            m = data[i++]; // num styles
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(value as Array);
+                comp.setStyle(name, value);
+            }
+            
+            m = data[i++]; // num effects
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                simple = data[i++];
+                value = data[i++];
+                if (simple == null)
+                    value = generateMXMLArray(value as Array, recursive);
+                else if (simple == false)
+                    value = generateMXMLObject(value as Array);
+                comp.setStyle(name, value);
+            }
+            
+            m = data[i++]; // num events
+            for (j = 0; j < m; j++)
+            {
+                name = data[i++];
+                value = data[i++];
+                comp.addEventListener(name, value);
+            }
+            
+            var children:Array = data[i++];
+            if (children)
+            {
+                if (recursive)
+                    comp.generateMXMLInstances(children, recursive);
+                else
+                    comp.setMXMLDescriptor(children);
+            }
+            if (id)
+            {
+                document[id] = comp;
+                mx.binding.BindingManager.executeBindings(document, id, comp); 
+            }
+            comps.push(comp);
+        }
+        return comps;
     }
  
     /**
@@ -907,6 +1078,15 @@ public class AddItems extends OverrideBase
             _waitingForDeferredContent = false;
         }   
     }
+    
+    /**
+     *  IMXMLObject support
+     */
+    public function initialized(document:Object, id:String):void
+    {
+        this.document = document;
+    }
+    
 }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/mx/src/mx/containers/ViewStack.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/containers/ViewStack.as b/frameworks/projects/mx/src/mx/containers/ViewStack.as
index e2b97d5..bf462ca 100644
--- a/frameworks/projects/mx/src/mx/containers/ViewStack.as
+++ b/frameworks/projects/mx/src/mx/containers/ViewStack.as
@@ -738,6 +738,15 @@ public class ViewStack extends Container implements IHistoryManagerClient, ISele
 
     /**
      *  @private
+     */	
+    override protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
+    {
+        // in theory, creationpolicy gets applied later
+        super.generateMXMLInstances(document, data, false);
+    }
+
+    /**
+     *  @private
      */
     override protected function commitProperties():void
     {

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/mx/src/mx/core/Container.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/core/Container.as b/frameworks/projects/mx/src/mx/core/Container.as
index 635d8bc..c3f7d91 100644
--- a/frameworks/projects/mx/src/mx/core/Container.as
+++ b/frameworks/projects/mx/src/mx/core/Container.as
@@ -4219,7 +4219,11 @@ public class Container extends UIComponent
      */
     public function createDeferredContent():void
     {
-        createComponentsFromDescriptors(true);
+        var children:Array =  this.MXMLDescriptor;
+        if (children)
+            generateMXMLInstances(document, children);
+        else
+            createComponentsFromDescriptors(true);
     }
 
    /**

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/spark/src/spark/components/Group.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/Group.as b/frameworks/projects/spark/src/spark/components/Group.as
index 7068fc5..f3a75fb 100644
--- a/frameworks/projects/spark/src/spark/components/Group.as
+++ b/frameworks/projects/spark/src/spark/components/Group.as
@@ -546,7 +546,15 @@ public class Group extends GroupBase implements IVisualElementContainer,
         
         }
     }
-
+    
+    /**
+     *  override setting of children
+     */
+    override protected function addMXMLChildren(comps:Array):void
+    {
+        mxmlContent = comps;
+    }
+    
     //----------------------------------
     //  mxmlContent
     //----------------------------------

http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/6907ac09/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
index f011a01..edff9c6 100644
--- a/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
+++ b/frameworks/projects/spark/src/spark/components/SkinnableContainer.as
@@ -672,6 +672,14 @@ public class SkinnableContainer extends SkinnableContainerBase
             _contentModified = true;
     }
     
+    /**
+     *  override setting of children
+     */
+    override protected function addMXMLChildren(comps:Array):void
+    {
+        mxmlContent = comps;
+    }
+    
     //----------------------------------
     //  mxmlContentFactory
     //----------------------------------
@@ -873,6 +881,17 @@ public class SkinnableContainer extends SkinnableContainerBase
     //
     //--------------------------------------------------------------------------
     
+    private var creatingChildren:Boolean;
+    
+    override protected function generateMXMLInstances(document:Object, data:Array, recursive:Boolean = true):void
+    {
+        // don't generate children during super.createChildren
+        if (creatingChildren)
+            return;
+        
+        super.generateMXMLInstances(document, data, recursive);
+    }
+
     /**
      *  Create content children, if the <code>creationPolicy</code> property 
      *  is not equal to <code>none</code>.
@@ -884,7 +903,9 @@ public class SkinnableContainer extends SkinnableContainerBase
      */
     override protected function createChildren():void
     {
+        creatingChildren = true;
         super.createChildren();
+        creatingChildren = false;
         
         // TODO (rfrishbe): When navigator support is added, this is where we would 
         // determine if content should be created now, or wait until
@@ -1048,6 +1069,16 @@ public class SkinnableContainer extends SkinnableContainerBase
      */
     public function createDeferredContent():void
     {
+        var children:Array =  this.MXMLDescriptor;
+        if (children)
+        {
+            generateMXMLInstances(document, children);
+            mxmlContentCreated = true; // keep the code from recursing back into here.
+            _deferredContentCreated = true; 
+            dispatchEvent(new FlexEvent(FlexEvent.CONTENT_CREATION_COMPLETE));
+            return;
+        }
+        
         if (!mxmlContentCreated)
         {
             mxmlContentCreated = true;