Consider positioning, plus first time around we may not have a parent.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/96fc3efd Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/96fc3efd Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/96fc3efd Branch: refs/heads/develop Commit: 96fc3efdec85c42817e5db14af38ce03d689797f Parents: ffa39f6 Author: yishayw <[email protected]> Authored: Mon Nov 21 13:07:13 2016 +0200 Committer: yishayw <[email protected]> Committed: Mon Nov 21 13:07:13 2016 +0200 ---------------------------------------------------------------------- .../flex/org/apache/flex/core/SimpleStatesImpl.as | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/96fc3efd/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as index 81b8f81..322bd48 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as @@ -126,7 +126,10 @@ package org.apache.flex.core for each (var item:IChild in ai.items) { var parent:IParent = item.parent as IParent; - parent.removeElement(item); + if (parent) + { + parent.removeElement(item); + } } if (parent is IContainer) IContainer(parent).childrenAdded(); @@ -193,10 +196,14 @@ package org.apache.flex.core index++; parent.addElementAt(item, index); } - else - { - parent.addElement(item); - } + else if (ai.position == "first") + { + parent.addElementAt(item, 0); + } + else + { + parent.addElement(item); + } } if (parent is IContainer) IContainer(parent).childrenAdded();
