Steven
Steven

Reputation: 1979

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

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.

Upvotes: 2

Views: 1300

Answers (3)

Adrian Pirvulescu
Adrian Pirvulescu

Reputation: 4340

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

So use:

(myViewStack.selectedChild as Container).id

Upvotes: 3

Florian F
Florian F

Reputation: 8875

var myCurrentSelectedChild:String = myViewStack.selectedChild.getChildAt(0).id;

Upvotes: 0

Related Questions