change from child.addToParent(parent) to parent.addChild(child)

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

Branch: refs/heads/develop
Commit: c12808827479a184a720a8c7e84d7bf9e46b7724
Parents: 92efcd3
Author: Alex Harui <[email protected]>
Authored: Mon Jul 22 14:25:52 2013 -0700
Committer: Alex Harui <[email protected]>
Committed: Mon Jul 22 14:49:53 2013 -0700

----------------------------------------------------------------------
 .../as/src/org/apache/flex/core/Application.as  |  53 ++++++++--
 .../as/src/org/apache/flex/core/IContainer.as   |   3 +-
 .../org/apache/flex/core/IItemRendererParent.as |   3 +-
 .../as/src/org/apache/flex/core/IParent.as      |  28 +++++
 .../as/src/org/apache/flex/core/IPopUpHost.as   |  24 +++++
 .../as/src/org/apache/flex/core/IUIBase.as      |   4 +-
 .../flex/core/ItemRendererClassFactory.as       |   4 +-
 .../org/apache/flex/core/SimpleStatesImpl.as    |  22 ++--
 .../as/src/org/apache/flex/core/UIBase.as       | 104 ++++++-------------
 .../as/src/org/apache/flex/core/UIButtonBase.as |  18 ++--
 .../as/src/org/apache/flex/core/ViewBase.as     |   4 +-
 .../src/org/apache/flex/createjs/Application.as |  13 ++-
 .../src/org/apache/flex/createjs/core/UIBase.as |   4 -
 .../org/apache/flex/createjs/core/ViewBase.as   |  28 ++++-
 .../apache/flex/html/staticControls/Alert.as    |   2 +-
 .../flex/html/staticControls/Container.as       |  41 ++++++--
 .../flex/html/staticControls/ControlBar.as      |   2 +-
 .../org/apache/flex/html/staticControls/List.as |   2 +-
 .../flex/html/staticControls/RadioButton.as     |   2 +-
 .../flex/html/staticControls/SimpleAlert.as     |   2 +-
 .../apache/flex/html/staticControls/TitleBar.as |   6 +-
 .../flex/html/staticControls/beads/AlertView.as |  15 +--
 .../html/staticControls/beads/ComboBoxView.as   |  10 +-
 .../staticControls/beads/DropDownListView.as    |  10 +-
 .../flex/html/staticControls/beads/ListView.as  |   8 +-
 .../staticControls/beads/NumericStepperView.as  |   5 +-
 .../flex/html/staticControls/beads/PanelView.as |   2 +-
 .../staticControls/beads/SimpleAlertView.as     |   5 +-
 .../html/staticControls/beads/TextAreaView.as   |   6 +-
 .../beads/TextInputWithBorderView.as            |   4 +-
 .../TextItemRendererFactoryForArrayData.as      |   9 +-
 ...extItemRendererFactoryForStringVectorData.as |   5 +-
 .../supportClasses/DropDownListList.as          |   2 +-
 .../supportClasses/TextFieldItemRenderer.as     |  16 ++-
 .../apache/flex/utils/MXMLDataInterpreter.as    |  17 +--
 35 files changed, 277 insertions(+), 206 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/Application.as 
b/frameworks/as/src/org/apache/flex/core/Application.as
index 81573d1..eef71d1 100644
--- a/frameworks/as/src/org/apache/flex/core/Application.as
+++ b/frameworks/as/src/org/apache/flex/core/Application.as
@@ -18,15 +18,13 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.core
 {
+    import flash.display.DisplayObject;
     import flash.display.Sprite;
     import flash.display.StageAlign;
     import flash.display.StageScaleMode;
-       
-       // this import is not used, but keeps the compiler from
-       // complaining about explicit usage of flash.events.Event
-       import flash.events.IOErrorEvent;
+    import flash.events.IOErrorEvent;
     
-       import org.apache.flex.events.Event;
+    import org.apache.flex.events.Event;
     import org.apache.flex.utils.MXMLDataInterpreter;
     
     //--------------------------------------
@@ -38,7 +36,7 @@ package org.apache.flex.core
      */
     [Event(name="initialize", type="org.apache.flex.events.Event")]
     
-    public class Application extends Sprite implements IStrand, IFlexInfo
+    public class Application extends Sprite implements IStrand, IFlexInfo, 
IParent
     {
         public function Application()
         {
@@ -62,7 +60,7 @@ package org.apache.flex.core
             dispatchEvent(new Event("initialize"));
 
             initialView.applicationModel =  model;
-           initialView.addToParent(this);
+           this.addElement(initialView);
            dispatchEvent(new Event("viewChanged"));
         }
 
@@ -126,5 +124,46 @@ package org.apache.flex.core
         {
             return {};           
         }
+        
+        public function addElement(c:Object):void
+        {
+            if (c is IUIBase)
+            {
+                addChild(IUIBase(c).element as DisplayObject);
+                IUIBase(c).addedToParent();
+            }
+            else
+                addChild(c as DisplayObject);
+        }
+        
+        public function addElementAt(c:Object, index:int):void
+        {
+            if (c is IUIBase)
+            {
+                addChildAt(IUIBase(c).element as DisplayObject, index);
+                IUIBase(c).addedToParent();
+            }
+            else
+                addChildAt(c as DisplayObject, index);
+        }
+
+        public function getElementIndex(c:Object):int
+        {
+            if (c is IUIBase)
+                return getChildIndex(IUIBase(c).element as DisplayObject);
+
+            return getChildIndex(c as DisplayObject);
+        }
+        
+        public function removeElement(c:Object):void
+        {
+            if (c is IUIBase)
+            {
+                removeChild(IUIBase(c).element as DisplayObject);
+            }
+            else
+                removeChild(c as DisplayObject);
+        }
+        
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/IContainer.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IContainer.as 
b/frameworks/as/src/org/apache/flex/core/IContainer.as
index edcd66f..630bdbc 100644
--- a/frameworks/as/src/org/apache/flex/core/IContainer.as
+++ b/frameworks/as/src/org/apache/flex/core/IContainer.as
@@ -18,9 +18,8 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.core
 {
-    public interface IContainer
+    public interface IContainer extends IParent
        {
-        function internalAddChild(child:Object):void;
                function childrenAdded():void;
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/IItemRendererParent.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IItemRendererParent.as 
b/frameworks/as/src/org/apache/flex/core/IItemRendererParent.as
index c693608..a9bc5a6 100644
--- a/frameworks/as/src/org/apache/flex/core/IItemRendererParent.as
+++ b/frameworks/as/src/org/apache/flex/core/IItemRendererParent.as
@@ -21,9 +21,8 @@ package org.apache.flex.core
        import flash.display.DisplayObject;
        import org.apache.flex.events.IEventDispatcher;
 
-       public interface IItemRendererParent extends IEventDispatcher
+       public interface IItemRendererParent extends IParent, IEventDispatcher
        {
                function getItemRendererForIndex(index:int):IItemRenderer;
-        function addChild(child:DisplayObject):DisplayObject;
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/IParent.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IParent.as 
b/frameworks/as/src/org/apache/flex/core/IParent.as
new file mode 100644
index 0000000..111c925
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IParent.as
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+    public interface IParent
+       {
+        function addElement(c:Object):void;
+        function addElementAt(c:Object, index:int):void;
+        function getElementIndex(c:Object):int;
+        function removeElement(c:Object):void;
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/IPopUpHost.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IPopUpHost.as 
b/frameworks/as/src/org/apache/flex/core/IPopUpHost.as
new file mode 100644
index 0000000..fc8a89a
--- /dev/null
+++ b/frameworks/as/src/org/apache/flex/core/IPopUpHost.as
@@ -0,0 +1,24 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+    public interface IPopUpHost extends IParent
+       {
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/IUIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/IUIBase.as 
b/frameworks/as/src/org/apache/flex/core/IUIBase.as
index cac4495..6b36a71 100644
--- a/frameworks/as/src/org/apache/flex/core/IUIBase.as
+++ b/frameworks/as/src/org/apache/flex/core/IUIBase.as
@@ -20,6 +20,8 @@ package org.apache.flex.core
 {
        public interface IUIBase extends IStrand
        {
-               function addToParent(p:Object):void;
+        function get element():Object;
+        
+               function addedToParent():void;
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/ItemRendererClassFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/ItemRendererClassFactory.as 
b/frameworks/as/src/org/apache/flex/core/ItemRendererClassFactory.as
index c6bd3aa..0dc1959 100644
--- a/frameworks/as/src/org/apache/flex/core/ItemRendererClassFactory.as
+++ b/frameworks/as/src/org/apache/flex/core/ItemRendererClassFactory.as
@@ -62,7 +62,7 @@ package org.apache.flex.core
 
         protected function 
createFromMXMLContent(parent:IItemRendererParent):IItemRenderer
         {
-            return MXMLDataInterpreter.generateMXMLArray(document, parent as 
DisplayObjectContainer, MXMLDescriptor, true)[0];
+            return MXMLDataInterpreter.generateMXMLArray(document, parent as 
IParent, MXMLDescriptor, true)[0];
         }
         
         public var itemRendererClass:Class;
@@ -70,7 +70,7 @@ package org.apache.flex.core
         public function 
createFromClass(parent:IItemRendererParent):IItemRenderer
         {
             var renderer:IItemRenderer = new itemRendererClass();
-            parent.addChild(renderer as DisplayObject);
+            parent.addElement(renderer);
             return renderer;
         }
         

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as 
b/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
index 76ba866..1e850a6 100644
--- a/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
+++ b/frameworks/as/src/org/apache/flex/core/SimpleStatesImpl.as
@@ -25,6 +25,7 @@ package org.apache.flex.core
     import mx.states.SetProperty;
     import mx.states.State;
     
+    import org.apache.flex.core.IParent;
     import org.apache.flex.events.Event;
     import org.apache.flex.events.EventDispatcher;
     import org.apache.flex.events.ValueChangeEvent;
@@ -78,11 +79,11 @@ package org.apache.flex.core
                     var ai:AddItems = AddItems(o);
                     for each (var item:DisplayObject in ai.items)
                     {
-                        var parent:Object = ai.document[ai.destination];
-                        if (item is UIBase)
-                            UIBase(item).removeFromParent(parent);
-                        parent.dispatchEvent(new Event("childrenAdded"));      
                  
+                        var parent:IParent = ai.document[ai.destination] as 
IParent;
+                        parent.removeElement(item);
                     }
+                    if (parent is IContainer)
+                        IContainer(parent).childrenAdded();
                 }
                 else if (o is SetProperty)
                 {
@@ -107,23 +108,22 @@ package org.apache.flex.core
                     }
                     for each (var item:DisplayObject in ai.items)
                     {
-                        var parent:Object = ai.document[ai.destination];
+                        var parent:IParent = ai.document[ai.destination] as 
IParent;
                         if (ai.relativeTo != null)
                         {
                             var child:Object = ai.document[ai.relativeTo];
-                            var index:int = 
UIBase(child).getIndexInParent(parent);
+                            var index:int = parent.getElementIndex(child);
                             if (ai.position == "after")
                                 index++;
-                            if (item is UIBase)
-                                UIBase(item).addToParentAt(parent, index);
+                            parent.addElementAt(item, index);
                         }
                         else
                         {
-                            if (item is IUIBase)
-                                IUIBase(item).addToParent(parent);
+                            parent.addElement(item);
                         }
-                        parent.dispatchEvent(new Event("childrenAdded"));
                     }
+                    if (parent is IContainer)
+                        IContainer(parent).childrenAdded();
                 }
                 else if (o is SetProperty)
                 {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/UIBase.as 
b/frameworks/as/src/org/apache/flex/core/UIBase.as
index 3b29870..944c942 100644
--- a/frameworks/as/src/org/apache/flex/core/UIBase.as
+++ b/frameworks/as/src/org/apache/flex/core/UIBase.as
@@ -24,7 +24,7 @@ package org.apache.flex.core
        import org.apache.flex.events.Event;
        import org.apache.flex.events.IEventDispatcher;
        
-       public class UIBase extends Sprite implements IStrand, 
IEventDispatcher, IUIBase
+       public class UIBase extends Sprite implements IStrand, 
IEventDispatcher, IUIBase, IParent
        {
                public function UIBase()
                {
@@ -127,6 +127,11 @@ package org.apache.flex.core
                                dispatchEvent(new Event("classNameChanged"));
                        }
                }
+        
+        public function get element():Object
+        {
+            return this;
+        }
                
                // beads declared in MXML are added to the strand.
                // from AS, just call addBead()
@@ -168,41 +173,45 @@ package org.apache.flex.core
                        return null;
                }
                
-               public function addToParent(p:Object):void
+               public function addElement(c:Object):void
                {
-                       if (p is UIBase)
-                               UIBase(p).internalAddChild(this);
+            if (c is IUIBase)
+            {
+                addChild(IUIBase(c).element as DisplayObject);
+                IUIBase(c).addedToParent();
+            }
             else
-                       p.addChild(this);
-            addedToParent();
+                addChild(c as DisplayObject);
                }
         
-        public function addToParentAt(p:Object, index:int):void
+        public function addElementAt(c:Object, index:int):void
         {
-            if (p is UIBase)
-                UIBase(p).internalAddChildAt(this, index);
+            if (c is IUIBase)
+            {
+                addChildAt(IUIBase(c).element as DisplayObject, index);
+                IUIBase(c).addedToParent();
+            }
             else
-                p.addChild(this, index);
-            addedToParent();
+                addChildAt(c as DisplayObject, index);
         }
         
-        public function getIndexInParent(p:Object):int
+        public function getElementIndex(c:Object):int
         {
-            if (p is UIBase)
-                return UIBase(p).internalGetChildIndex(this);
+            if (c is IUIBase)
+                return getChildIndex(IUIBase(c).element as DisplayObject);
             else
-                return p.getChildIndex(this);
+                return getChildIndex(c as DisplayObject);
         }
 
-        public function removeFromParent(p:Object):void
+        public function removeElement(c:Object):void
         {
-            if (p is UIBase)
-                UIBase(p).internalRemoveChild(this);
+            if (c is IUIBase)
+                removeChild(IUIBase(c).element as DisplayObject);
             else
-                p.removeChild(this);
+                removeChild(c as DisplayObject);
         }
                
-        protected function addedToParent():void
+        public function addedToParent():void
         {
             var c:Class;
             
@@ -237,60 +246,7 @@ package org.apache.flex.core
                 }
             }
         }
-        
-               /**
-                * Used internally by addToParent() implementations
-                * to determine attach a child to a parent.  Containers
-                * may host controls in a sub-component in order to
-                * manage scrolling and margins and other internal abstractions.
-                * Each platform assumes that the appropriate platform call
-                * will add the child to the parent (i.e. addChild on Flash, 
-                * appendChild on HTML).
-                */
-               public function internalAddChild(child:Object):void
-               {
-                       addChild(child as DisplayObject);
-               }
-
-        public function internalAddChildAt(child:Object, index:int):void
-        {
-            addChildAt(child as DisplayObject, index);
-        }
-        
-        public function internalGetChildIndex(child:Object):int
-        {
-            return getChildIndex(child as DisplayObject);
-        }
-        
-        public function internalRemoveChild(child:Object):void
-        {
-            removeChild(child as DisplayObject);
-        }
-
-        /*
-        public function addToParent(p:Object):void
-        {
-            var doc:DisplayObjectContainer = p as DisplayObjectContainer;
-            if (p is UIBase)
-                doc = UIBase(p).getParentForChild(this) as 
DisplayObjectContainer;
-            doc.addChild(this);
-        }
-        */
-        
-        /**
-         * Used internally by addToParent() implementations
-         * to determine suitable parent for a child.  Containers
-         * may host controls in a sub-component in order to
-         * manage scrolling and margins and other internal abstractions.
-         * Each platform assumes that the appropriate platform call
-         * will add the child to the parent (i.e. addChild on Flash, 
-         * appendTo on HTML).
-        public function getParentForChild(child:Object):Object
-        {
-            return this;
-        }
-         */
-               
+                       
                public function get measurementBead() : IMeasurementBead
                {
                        var measurementBead:IMeasurementBead = 
getBeadByType(IMeasurementBead) as IMeasurementBead;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/UIButtonBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/UIButtonBase.as 
b/frameworks/as/src/org/apache/flex/core/UIButtonBase.as
index 9a8ee1f..529cc60 100644
--- a/frameworks/as/src/org/apache/flex/core/UIButtonBase.as
+++ b/frameworks/as/src/org/apache/flex/core/UIButtonBase.as
@@ -151,6 +151,11 @@ package org.apache.flex.core
                                dispatchEvent(new Event("classNameChanged"));
                        }
                }
+        
+        public function get element():Object
+        {
+            return this;
+        }
 
         // beads declared in MXML are added to the strand.
         // from AS, just call addBead()
@@ -192,7 +197,7 @@ package org.apache.flex.core
                        return null;
                }
                
-               protected function addedToParent():void
+               public function addedToParent():void
                {
             var c:Class;
             
@@ -232,17 +237,6 @@ package org.apache.flex.core
             
                }
                
-               public function addToParent(p:Object):void
-               {
-                       if( p is UIBase ) {
-                               UIBase(p).internalAddChild(this);
-                       }
-                       else if( p is DisplayObjectContainer ) {
-                               p.addChild(this);
-                       }
-            addedToParent();
-               }
-               
                public function get measurementBead() : IMeasurementBead
                {
                        var measurementBead:IMeasurementBead = 
getBeadByType(IMeasurementBead) as IMeasurementBead;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/core/ViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/ViewBase.as 
b/frameworks/as/src/org/apache/flex/core/ViewBase.as
index e78d243..3e92893 100644
--- a/frameworks/as/src/org/apache/flex/core/ViewBase.as
+++ b/frameworks/as/src/org/apache/flex/core/ViewBase.as
@@ -27,14 +27,14 @@ package org.apache.flex.core
 
        [Event(name="initComplete", type="org.apache.flex.events.Event")]
        [DefaultProperty("mxmlContent")]
-       public class ViewBase extends UIBase
+       public class ViewBase extends UIBase implements IPopUpHost
        {
                public function ViewBase()
                {
                        super();
                }
                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
                        // each MXML file can also have styles in fx:Style block
                        ValuesManager.valuesImpl.init(this);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/createjs/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/createjs/Application.as 
b/frameworks/as/src/org/apache/flex/createjs/Application.as
index a9fdfec..2214325 100644
--- a/frameworks/as/src/org/apache/flex/createjs/Application.as
+++ b/frameworks/as/src/org/apache/flex/createjs/Application.as
@@ -18,18 +18,16 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.createjs
 {
+       import flash.display.DisplayObject;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
-       
-       // this import is not used, but keeps the compiler from
-       // complaining about explicit usage of flash.events.Event
        import flash.events.IOErrorEvent;
        
-//     import org.apache.flex.core.Application;
        import org.apache.flex.core.IBead;
        import org.apache.flex.core.IFlexInfo;
        import org.apache.flex.core.IStrand;
+       import org.apache.flex.core.IUIBase;
        import org.apache.flex.core.IValuesImpl;
        import org.apache.flex.core.ValuesManager;
        import org.apache.flex.createjs.core.ViewBase;
@@ -68,7 +66,7 @@ package org.apache.flex.createjs
                        
                        dispatchEvent(new Event("initialize"));
                        
-                       initialView.addToParent(this);
+                       addElement(initialView);
                        initialView.initUI(model);
                        dispatchEvent(new Event("viewChanged"));
                }
@@ -133,5 +131,10 @@ package org.apache.flex.createjs
                {
                        return {};           
                }
+        
+        public function addElement(c:Object):void
+        {
+            addChild(c as DisplayObject);
+        }
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/createjs/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/createjs/core/UIBase.as 
b/frameworks/as/src/org/apache/flex/createjs/core/UIBase.as
index 20bf5e0..d0761a0 100644
--- a/frameworks/as/src/org/apache/flex/createjs/core/UIBase.as
+++ b/frameworks/as/src/org/apache/flex/createjs/core/UIBase.as
@@ -137,9 +137,5 @@ package org.apache.flex.createjs.core
                        return null;
                }
                
-               public function addToParent(p:DisplayObjectContainer):void
-               {
-                       p.addChild(this);
-               }
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/createjs/core/ViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/createjs/core/ViewBase.as 
b/frameworks/as/src/org/apache/flex/createjs/core/ViewBase.as
index 434d6dd..195821f 100644
--- a/frameworks/as/src/org/apache/flex/createjs/core/ViewBase.as
+++ b/frameworks/as/src/org/apache/flex/createjs/core/ViewBase.as
@@ -18,11 +18,15 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.createjs.core
 {
+       import flash.display.DisplayObject;
+       
+       import org.apache.flex.core.IParent;
+       import org.apache.flex.core.IUIBase;
        import org.apache.flex.events.Event;
        import org.apache.flex.utils.MXMLDataInterpreter;
        
        [DefaultProperty("mxmlContent")]
-       public class ViewBase extends UIBase
+       public class ViewBase extends UIBase implements IParent
        {
                public function ViewBase()
                {
@@ -56,5 +60,27 @@ package org.apache.flex.createjs.core
                {
                        return _applicationModel;
                }
+        
+        public function addElement(c:Object):void
+        {
+            addChild(c as DisplayObject);
+        }
+
+        public function addElementAt(c:Object, index:int):void
+        {
+            addChildAt(c as DisplayObject, index);
+        }
+        
+        public function getElementIndex(c:Object):int
+        {
+            return getChildIndex(c as DisplayObject);
+        }
+        
+        public function removeElement(c:Object):void
+        {
+            removeChild(c as DisplayObject);
+        }
+        
+
        }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
index 22e9cfe..b3cf5e2 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Alert.as
@@ -51,7 +51,7 @@ package org.apache.flex.html.staticControls
                
                public function show(parent:Object) : void
                {
-                       addToParent(parent);
+                       parent.addElement(this);
                }
                
                public function get title():String

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/Container.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
index 2263852..8d7b2b7 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/Container.as
@@ -22,6 +22,7 @@ package org.apache.flex.html.staticControls
        import flash.display.DisplayObjectContainer;
        
        import org.apache.flex.core.IContainer;
+       import org.apache.flex.core.IUIBase;
        import org.apache.flex.core.UIBase;
        import org.apache.flex.events.Event;
        
@@ -45,26 +46,44 @@ package org.apache.flex.html.staticControls
                        actualParent = parent;  
                }
                
-               override public function internalAddChild(child:Object):void
-               {
-                       actualParent.addChild(child as DisplayObject);
-               }
+        override public function getElementIndex(c:Object):int
+        {
+            if (c is IUIBase)
+                return actualParent.getChildIndex(IUIBase(c).element as 
DisplayObject);
+            else
+                return actualParent.getChildIndex(c as DisplayObject);
+        }
 
-        override public function internalAddChildAt(child:Object, 
index:int):void
+        override public function addElement(c:Object):void
         {
-            actualParent.addChildAt(child as DisplayObject, index);
+            if (c is IUIBase)
+            {
+                actualParent.addChild(IUIBase(c).element as DisplayObject);
+                IUIBase(c).addedToParent();
+            }
+            else
+                actualParent.addChild(c as DisplayObject);
         }
         
-        override public function internalGetChildIndex(child:Object):int
+        override public function addElementAt(c:Object, index:int):void
         {
-            return actualParent.getChildIndex(child as DisplayObject);
+            if (c is IUIBase)
+            {
+                actualParent.addChildAt(IUIBase(c).element as DisplayObject, 
index);
+                IUIBase(c).addedToParent();
+            }
+            else
+                actualParent.addChildAt(c as DisplayObject, index);
         }
         
-        override public function internalRemoveChild(child:Object):void
+        override public function removeElement(c:Object):void
         {
-            actualParent.removeChild(child as DisplayObject);
+            if (c is IUIBase)
+                actualParent.removeChild(IUIBase(c).element as DisplayObject);
+            else
+                actualParent.removeChild(c as DisplayObject);
         }
-
+        
         public function getChildren():Array
                {
                        var children:Array = [];

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/ControlBar.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/ControlBar.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/ControlBar.as
index d0b3721..e805ff1 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/ControlBar.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/ControlBar.as
@@ -32,7 +32,7 @@ package org.apache.flex.html.staticControls
                        className = "ControlBar";
                }
                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
                        super.addedToParent();  
                        

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/List.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/List.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/List.as
index a80081c..7cb3b6d 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/List.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/List.as
@@ -66,7 +66,7 @@ package org.apache.flex.html.staticControls
                        ISelectionModel(model).selectedItem = value;
                }
                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
             super.addedToParent();
             

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
index 39589fa..8f31816 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/RadioButton.as
@@ -105,7 +105,7 @@ package org.apache.flex.html.staticControls
                        IValueToggleButtonModel(model).selectedValue = newValue;
                }
                                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
             super.addedToParent();
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
index 9eae0dd..cf4cc8c 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/SimpleAlert.as
@@ -54,7 +54,7 @@ package org.apache.flex.html.staticControls
                
                public function show(parent:Object) : void
                {
-                       addToParent(parent);
+                       parent.addElement(this);
                }
                
                static public function show(message:String, 
parent:Object):SimpleAlert

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
index 3423955..c7419ef 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/TitleBar.as
@@ -75,7 +75,7 @@ package org.apache.flex.html.staticControls
                        return closeButton;
                }
                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
                        super.addedToParent();
                        
@@ -86,12 +86,12 @@ package org.apache.flex.html.staticControls
                        _titleLabel = createTitle();
                        _titleLabel.className = className;
                        _titleLabel.id = "title";
-                       _titleLabel.addToParent(this);
+                       addElement(_titleLabel);
                        
                        _closeButton = createCloseButton();
                        _closeButton.className = className;
                        _closeButton.id = "closeButton";
-                       _closeButton.addToParent(this);
+                       addElement(_closeButton);
                        
                        childrenAdded();
             

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as
index 71e04cf..b02911a 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/AlertView.as
@@ -22,6 +22,7 @@ package org.apache.flex.html.staticControls.beads
        import org.apache.flex.core.IBead;
     import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IMeasurementBead;
+    import org.apache.flex.core.IParent;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.UIBase;
        import org.apache.flex.core.UIMetrics;
@@ -107,14 +108,14 @@ package org.apache.flex.html.staticControls.beads
                        _label.text = 
IAlertModel(UIBase(_strand).model).message;
                        
                        _controlBar = new ControlBar();
-                       if( _okButton ) _okButton.addToParent(_controlBar);
-                       if( _cancelButton ) 
_cancelButton.addToParent(_controlBar);
-                       if( _yesButton  ) _yesButton.addToParent(_controlBar);
-                       if( _noButton ) _noButton.addToParent(_controlBar);
+                       if( _okButton ) _controlBar.addElement(_okButton);
+                       if( _cancelButton ) 
_controlBar.addElement(_cancelButton);
+                       if( _yesButton  ) _controlBar.addElement(_yesButton);
+                       if( _noButton ) _controlBar.addElement(_noButton);
                        
-                       _titleBar.addToParent(_strand);
-                       _controlBar.addToParent(_strand);
-                       _label.addToParent(_strand);
+                   IParent(_strand).addElement(_titleBar);
+            IParent(_strand).addElement(_controlBar);
+            IParent(_strand).addElement(_label);
                        
                        sizeHandler(null);
                }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as
index 6d60ac9..d7a5bba 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ComboBoxView.as
@@ -24,9 +24,10 @@ package org.apache.flex.html.staticControls.beads
        
        import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IComboBoxModel;
-       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.core.IPopUpHost;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.ValuesManager;
+    import org.apache.flex.core.IParent;
        import org.apache.flex.events.Event;
        import org.apache.flex.events.IEventDispatcher;
        import org.apache.flex.html.staticControls.Button;
@@ -75,7 +76,7 @@ package org.apache.flex.html.staticControls.beads
                        selectionModel.addEventListener("selectedIndexChanged", 
selectionChangeHandler);
             
                        textInput = new TextInput();
-                       textInput.addToParent(DisplayObjectContainer(strand));
+                       IParent(strand).addElement(textInput);
                        textInput.width = 100;
                        textInput.height = 18;
                        
@@ -148,9 +149,10 @@ package org.apache.flex.html.staticControls.beads
                                        }
                                        var root:Object = 
DisplayObject(_strand).root;
                                        var host:DisplayObjectContainer = 
DisplayObject(_strand).parent;
-                                       while (host.parent != root)
+                                       while (host && !(host is IPopUpHost))
                                                host = host.parent;
-                                       IUIBase(popUp).addToParent(host);
+                    if (host)
+                                       IPopUpHost(host).addElement(popUp);
                                }
                                else
                                {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/DropDownListView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/DropDownListView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DropDownListView.as
index 24222cc..59954ed 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/DropDownListView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/DropDownListView.as
@@ -28,9 +28,10 @@ package org.apache.flex.html.staticControls.beads
        
        import org.apache.flex.core.CSSTextField;
        import org.apache.flex.core.IBeadView;
+       import org.apache.flex.core.IPopUpHost;
        import org.apache.flex.core.ISelectionModel;
        import org.apache.flex.core.IStrand;
-       import org.apache.flex.core.IUIBase;
+       import org.apache.flex.core.IPopUpHost;
        import org.apache.flex.core.ValuesManager;
        import org.apache.flex.events.Event;
        import org.apache.flex.events.IEventDispatcher;
@@ -206,9 +207,10 @@ package org.apache.flex.html.staticControls.beads
                     }
                                        var root:Object = 
DisplayObject(_strand).root;
                                        var host:DisplayObjectContainer = 
DisplayObject(_strand).parent;
-                                       while (host.parent != root)
-                                               host = host.parent;
-                    IUIBase(_popUp).addToParent(host);
+                    while (host && !(host is IPopUpHost))
+                        host = host.parent;
+                    if (host)
+                        IPopUpHost(host).addElement(popUp);
                 }
                 else
                 {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as
index 2ace491..559435e 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/ListView.as
@@ -25,7 +25,7 @@ package org.apache.flex.html.staticControls.beads
        import org.apache.flex.core.ISelectionModel;
        import org.apache.flex.core.IStrand;
        import org.apache.flex.core.Strand;
-       import org.apache.flex.core.UIBase;
+       import org.apache.flex.core.IParent;
        import org.apache.flex.core.ValuesManager;
        import org.apache.flex.events.Event;
        import org.apache.flex.html.staticControls.beads.models.ScrollBarModel;
@@ -81,10 +81,10 @@ package org.apache.flex.html.staticControls.beads
             _border = new Border();
             _border.model = new SingleLineBorderModel();
             _border.addBead(new SingleLineBorderBead());
-            border.addToParent(UIBase(_strand));
+            IParent(_strand).addElement(_border);
             
                        _dataGroup = new NonVirtualDataGroup();
-                       UIBase(_dataGroup).addToParent(UIBase(_strand));
+                       IParent(_strand).addElement(_dataGroup);
             
             if (getBeadByType(IBeadLayout) == null)
             {
@@ -124,7 +124,7 @@ package org.apache.flex.html.staticControls.beads
                        vsbm.value = 0;
                        vsb.model = vsbm;
                        vsb.width = 16;
-            vsb.addToParent(UIBase(_strand));
+            IParent(_strand).addElement(vsb);
                        return vsb;
                }
                                

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as
index 43e877f..0fa04cc 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/NumericStepperView.as
@@ -21,6 +21,7 @@ package org.apache.flex.html.staticControls.beads
        import org.apache.flex.core.IBeadModel;
        import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.IParent;
        import org.apache.flex.core.UIBase;
        import org.apache.flex.createjs.staticControls.Label;
        import org.apache.flex.events.Event;
@@ -50,12 +51,12 @@ package org.apache.flex.html.staticControls.beads
             
                        // add an input field
                        input = new TextInput();
-                       input.addToParent(value);
+                       IParent(value).addElement(input);
                        
                        // add a spinner
                        spinner = new Spinner();
                        spinner.addBead( UIBase(value).model );
-                       spinner.addToParent(value);
+                       IParent(value).addElement(spinner);
                        spinner.width = 17;
                        
                        // listen for changes to the text input field which 
will reset the

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelView.as
index 8fd91c8..7884845 100644
--- a/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelView.as
+++ b/frameworks/as/src/org/apache/flex/html/staticControls/beads/PanelView.as
@@ -64,7 +64,7 @@ package org.apache.flex.html.staticControls.beads
                                _controlBar = new ControlBar();
                                
                                for each(var comp:IUIBase in controlBarItems) {
-                                       comp.addToParent(_controlBar);
+                                       _controlBar.addElement(comp);
                                }
                                
                                Container(_strand).addChild(controlBar);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertView.as
index cd4f817..b5748d0 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/SimpleAlertView.as
@@ -23,6 +23,7 @@ package org.apache.flex.html.staticControls.beads
     import org.apache.flex.core.IBeadView;
        import org.apache.flex.core.IMeasurementBead;
        import org.apache.flex.core.IStrand;
+    import org.apache.flex.core.IParent;
        import org.apache.flex.core.UIBase;
        import org.apache.flex.core.UIMetrics;
        import org.apache.flex.core.ValuesManager;
@@ -77,11 +78,11 @@ package org.apache.flex.html.staticControls.beads
             messageLabel = new Label();
                        messageLabel.text = model.message;
                        messageLabel.html = model.htmlMessage;
-                       messageLabel.addToParent(_strand);
+                       IParent(_strand).addElement(messageLabel);
                        
                        okButton = new TextButton();
                        okButton.text = model.okLabel;
-                       okButton.addToParent(_strand);
+                       IParent(_strand).addElement(okButton);
                        okButton.addEventListener("click",handleOK);
                        
                        handleMessageChange(null);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as
index 61504f6..b400c6c 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextAreaView.as
@@ -26,7 +26,7 @@ package org.apache.flex.html.staticControls.beads
        import org.apache.flex.core.IBead;
        import org.apache.flex.core.IScrollBarModel;
        import org.apache.flex.core.IStrand;
-       import org.apache.flex.core.UIBase;
+       import org.apache.flex.core.IParent;
        import org.apache.flex.html.staticControls.beads.models.ScrollBarModel;
        import 
org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
        import org.apache.flex.html.staticControls.supportClasses.Border;
@@ -69,7 +69,7 @@ package org.apache.flex.html.staticControls.beads
                        _border = new Border();
                        _border.model = new SingleLineBorderModel();
                        _border.addBead(new SingleLineBorderBead());
-            border.addToParent(UIBase(strand));
+            IParent(strand).addElement(border);
                        
                        var vb:ScrollBar = vScrollBar;
                        
@@ -103,7 +103,7 @@ package org.apache.flex.html.staticControls.beads
                        vsbm.value = 0;
                        vsb.model = vsbm;
                        vsb.width = 16;
-            vsb.addToParent(UIBase(strand));
+            IParent(strand).addElement(vsb);
                        
                        vsb.addEventListener("scroll", scrollHandler);
                        

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as
index eb8a6dd..8d5e405 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextInputWithBorderView.as
@@ -21,7 +21,7 @@ package org.apache.flex.html.staticControls.beads
        import flash.display.DisplayObject;
        
        import org.apache.flex.core.IStrand;
-       import org.apache.flex.core.UIBase;
+       import org.apache.flex.core.IParent;
        import 
org.apache.flex.html.staticControls.beads.models.SingleLineBorderModel;
        import org.apache.flex.html.staticControls.supportClasses.Border;
        import org.apache.flex.events.Event;
@@ -49,7 +49,7 @@ package org.apache.flex.html.staticControls.beads
                        _border = new Border();
                        _border.model = new SingleLineBorderModel();
                        _border.addBead(new SingleLineBorderBead());
-            border.addToParent(UIBase(strand));
+            IParent(strand).addElement(border);
                        
                        
IEventDispatcher(strand).addEventListener("widthChanged", sizeChangedHandler);
                        
IEventDispatcher(strand).addEventListener("heightChanged", sizeChangedHandler);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.as
index a8608e6..ff4678e 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.as
@@ -18,14 +18,11 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.html.staticControls.beads
 {
-    import flash.display.DisplayObject;
-    
     import org.apache.flex.core.IBead;
     import org.apache.flex.core.IItemRendererClassFactory;
     import org.apache.flex.core.IItemRendererParent;
     import org.apache.flex.core.ISelectionModel;
     import org.apache.flex.core.IStrand;
-    import org.apache.flex.core.IUIBase;
     import org.apache.flex.core.ValuesManager;
     import org.apache.flex.events.Event;
 
@@ -81,11 +78,7 @@ package org.apache.flex.html.staticControls.beads
                        {
                                var tf:ITextItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as ITextItemRenderer;
                 tf.index = i;
-                if (tf is IUIBase)
-                    IUIBase(tf).addToParent(dataGroup);
-                else
-
-                               dataGroup.addChild(tf as DisplayObject);
+                dataGroup.addElement(tf);
                                tf.text = dp[i];
                        }                       
                }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForStringVectorData.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForStringVectorData.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForStringVectorData.as
index 830841a..c72561b 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForStringVectorData.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForStringVectorData.as
@@ -61,10 +61,7 @@ package org.apache.flex.html.staticControls.beads
                        {
                                var tf:ITextItemRenderer = 
itemRendererFactory.createItemRenderer(dataGroup) as ITextItemRenderer;
                 tf.index = i;
-                if (tf is IUIBase)
-                    IUIBase(tf).addToParent(dataGroup);
-                else
-                               dataGroup.addChild(tf as DisplayObject);
+                dataGroup.addElement(tf);
                                tf.text = dp[i];
                        }                       
                }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DropDownListList.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DropDownListList.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DropDownListList.as
index df61a7a..d42a739 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DropDownListList.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/DropDownListList.as
@@ -31,7 +31,7 @@ package org.apache.flex.html.staticControls.supportClasses
                        super();
                }
                
-               override protected function addedToParent():void
+               override public function addedToParent():void
                {
                        super.addedToParent();
                        

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/TextFieldItemRenderer.as
----------------------------------------------------------------------
diff --git 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/TextFieldItemRenderer.as
 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/TextFieldItemRenderer.as
index 2d13262..6288951 100644
--- 
a/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/TextFieldItemRenderer.as
+++ 
b/frameworks/as/src/org/apache/flex/html/staticControls/supportClasses/TextFieldItemRenderer.as
@@ -163,6 +163,11 @@ package org.apache.flex.html.staticControls.supportClasses
             else if (selected)
                 backgroundColor = selectedColor;
         }
+        
+        public function get element():Object
+        {
+            return this;
+        }
 
         // beads declared in MXML are added to the strand.
         // from AS, just call addBead()
@@ -202,16 +207,7 @@ package org.apache.flex.html.staticControls.supportClasses
             return null;
         }
         
-        public function addToParent(p:Object):void
-        {
-            if (p is UIBase)
-                UIBase(p).internalAddChild(this);
-            else
-                p.addChild(this);
-            addedToParent();
-        }
-
-        protected function addedToParent():void
+        public function addedToParent():void
         {
             var c:Class;
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c1280882/frameworks/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/utils/MXMLDataInterpreter.as 
b/frameworks/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
index 8340ee6..3538e51 100644
--- a/frameworks/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
+++ b/frameworks/as/src/org/apache/flex/utils/MXMLDataInterpreter.as
@@ -18,13 +18,11 @@
 
////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.utils
 {
-import flash.display.DisplayObject;
-import flash.display.DisplayObjectContainer;
 
 import org.apache.flex.core.IStrand;
 import org.apache.flex.core.IBead;
 import org.apache.flex.core.IDocument;
-import org.apache.flex.core.IUIBase;
+import org.apache.flex.core.IParent;
 import org.apache.flex.core.IContainer;
 
 public class MXMLDataInterpreter
@@ -76,7 +74,7 @@ public class MXMLDataInterpreter
         return comp;
     }
     
-    public static function generateMXMLArray(document:Object, 
parent:DisplayObjectContainer, data:Array, recursive:Boolean = true):Array
+    public static function generateMXMLArray(document:Object, parent:IParent, 
data:Array, recursive:Boolean = true):Array
     {
         var comps:Array = [];
         
@@ -191,12 +189,7 @@ public class MXMLDataInterpreter
             
             if (parent)
             {
-                if (comp is IUIBase)
-                    comp.addToParent(parent);
-                else if (parent is IContainer)
-                    IContainer(parent).internalAddChild(comp as DisplayObject);
-                else if (comp is DisplayObject)
-                    parent.addChild(comp as DisplayObject);
+                parent.addElement(comp);
             }
 
             var children:Array = data[i++];
@@ -204,7 +197,7 @@ public class MXMLDataInterpreter
             {
                 if (recursive)
                                {
-                    generateMXMLInstances(document, comp as 
DisplayObjectContainer, children, recursive);
+                    generateMXMLInstances(document, comp as IParent, children, 
recursive);
                                        if (comp is IContainer)
                                        {
                                                
IContainer(comp).childrenAdded();
@@ -224,7 +217,7 @@ public class MXMLDataInterpreter
         return comps;
     }
     
-    public static function generateMXMLInstances(document:Object, 
parent:DisplayObjectContainer, data:Array, recursive:Boolean = true):void
+    public static function generateMXMLInstances(document:Object, 
parent:IParent, data:Array, recursive:Boolean = true):void
     {
                if (!data) return;
                

Reply via email to