-1

I'm getting the following error:

1067: Implicit coercion of a value of type String to an unrelated type mx.core:INavigatorContent.

Which is located in my main application at the line where I set the selectedChild=

Here's my code for my viewstack which is in my main application:

<mx:ViewStack id="mainViewStack"
                      width="100%" height="100%"
                      selectedChild="{topViewControlComponent.selectedChild}">

My component contains the following:

[Bindable]
            public var selectedChild:String;

            protected function changeView2(child:String):void
            {
                this.selectedChild = child;
            }

<s:Button styleName="controlBarButton"
              label="Events"
              click="changeView2('userEvents');"/>

I got this to work when I set the viewstack navigator content base off of selectIndex and using an integer...worked fine. But I would rather call them by the id of the Navigator content so that they don't have to be in specific order, if this is possible. Or maybe there's a better way to go about this...Thanks for any help!

ketan
  • 19,129
  • 42
  • 60
  • 98
Omgabee
  • 97
  • 10

1 Answers1

1

The selectedChild property on the ViewStack takes an actual view as its argument, not the name of a view. Using selectedIndex with an int will work fine, or you could call a function in your main application that maps between id and view instance.

Edit: As you said in the comments, you can use click="mainViewStack.selectedChild=userEvents" to set the view as desired.

However, your code in the question is acting like this:

click="mainViewStack.selectedChild='userEvents'"
Brian
  • 3,850
  • 3
  • 21
  • 37
  • Not sure what the difference is ("takes an actual view as its argument, not the name of a view"), I can select the view with this for instance: click="mainViewStack.selectedChild=userEvents" (but only if I use it in the main application). Guess I'm just confused by this...I only started using Flex 4.6 one week ago -.-; – Omgabee Sep 30 '14 at 18:09
  • `mainViewStack.selectedChild` needs to be a view-type variable. You're getting an error because you're passing in a string -- i.e. just the *name* of your desired view. – Brian Sep 30 '14 at 18:17
  • Okay, thank you, that clears it up a little. I'll have to go research that variable type then and figure out how I will do this. Thanks again. – Omgabee Sep 30 '14 at 18:20
  • In response to your edit: "However, your code in the question is acting like this: click="mainViewStack.selectedChild='userEvents'"" It woudln't work unless I added the single quotes, so assumed I needed them. And by "wouldn't work" I mean that specific line showed an error which went away when I added the quotes....But I see what you're saying...it is taking the name literally. – Omgabee Sep 30 '14 at 19:39