Issue getting viewState's selected child's id in flex 4

1.3k Views Asked by At

I'm transitioning a flex 3 application to flex 4. There was AS code in the flex 3 app that worked:

var myCurrentSelectedChild:String = myViewStack.selectedChild.id;

Now, in flash builder and flex 4.5, it throws the error - "-1119: Access of possibly undefined property id through a reference with static type mx.core:INavigatorContent". I'm trying to get the viewStack's selected child's id.

3

There are 3 best solutions below

0
Adrian Pirvulescu On BEST ANSWER

Try to cast the myViewStack.selectedChild to some UI Object type. core:INavigatorContent has no ID property.

So use:

(myViewStack.selectedChild as Container).id
1
Florian F On
var myCurrentSelectedChild:String = myViewStack.selectedChild.getChildAt(0).id;
0
josef On