flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [02/14] git commit: [flex-asjs] [refs/heads/develop] - fix which parent is used for adding/removing items
Date Fri, 31 Oct 2014 22:08:37 GMT
fix which parent is used for adding/removing items


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

Branch: refs/heads/develop
Commit: 9b347d463587ed28b875af78a9640ac38901c02b
Parents: 83c26c9
Author: Alex Harui <aharui@apache.org>
Authored: Thu Oct 30 21:37:40 2014 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Oct 31 15:08:14 2014 -0700

----------------------------------------------------------------------
 .../org/apache/flex/core/SimpleStatesImpl.as    | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9b347d46/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
index 6fb6457..0783e28 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/SimpleStatesImpl.as
@@ -60,6 +60,8 @@ package org.apache.flex.core
         
         private var _strand:IStrand;
         
+        private var sawInitComplete:Boolean;
+        
         /**
          *  @copy org.apache.flex.core.IBead#strand
          *  
@@ -77,12 +79,16 @@ package org.apache.flex.core
         
         private function initialStateHandler(event:org.apache.flex.events.Event):void
         {
+            sawInitComplete = true;
             stateChangeHandler(new ValueChangeEvent("currentStateChange", false, false, null,

                 IStatesObject(_strand).currentState));
         }		
      
         private function stateChangeHandler(event:ValueChangeEvent):void
         {
+            if (!sawInitComplete)
+                return;
+            
             var doc:IStatesObject = _strand as IStatesObject;
             var arr:Array = doc.states;
             for each (var s:State in arr)
@@ -114,9 +120,7 @@ package org.apache.flex.core
                     var ai:AddItems = AddItems(o);
                     for each (var item:DisplayObject in ai.items)
                     {
-                        var parent:IParent = ai.document as IParent;
-                        if (ai.destination != null)
-                            parent = parent[ai.destination] as IParent;
+                        var parent:IParent = item.parent as IParent;
                         parent.removeElement(item);
                     }
                     if (parent is IContainer)
@@ -171,14 +175,11 @@ package org.apache.flex.core
                             parent = parent[ai.destination] as IParent;
                         if (ai.relativeTo != null)
                         {
-                            var index:int = parent.numElements;
-                            if (ai.relativeTo != null)
-                            {
-                                var child:Object = ai.document[ai.relativeTo];
-                                index = parent.getElementIndex(child);
-                                if (ai.position == "after")
-                                    index++;
-                            }
+                            var child:Object = ai.document[ai.relativeTo];
+                            parent = child.parent as IParent;
+                            var index:int = parent.getElementIndex(child);
+                            if (ai.position == "after")
+                                index++;
                             parent.addElementAt(item, index);
                         }
                         else


Mime
View raw message