tags:

views:

1004

answers:

1

I understand that we need to create MXML file to define a view. Suppose on user click of a button I want to show another view defined in another MXML file. How can I do this?

+3  A: 

You could use a viewstack. each item in the viewstack would be a different MXML file so when the user clicks a button you change the selected index of the viewstack which makes the view change.

You could probably do with checking out the examples in http://www.adobe.com/devnet/flex/tourdeflex/ this will help explain so much more than a simple answer will. From your question it sounds like you need to get the basics of flex first and the tour de flex app contains loads of examples with source code. HTH.

kenneth
I have already checked the viesstack example but that doesn't answer my question. I specifically asked where both the views are defined in two separate MXML file. Is that not possible in Flex?
Bhushan
Yes it does answer your question. You just need to learn a bit more about flex. Each part/node of the viewstack can be a separate mxml or actionscript file.If you have something like<mx:ViewStack><mx:Canvas></mx:Canvas><local:MyCanvas ></local:MyCanvas ></mx:ViewStack>Then this will use the separate file from Adobe called Canvas then it will use MyCanvas (which you'll have coded) as the second child of the viewstack.
kenneth
I should also say if you look at the viewstack example from tour de flex then what you could do is create 3 separate files that are based on the VBox and copy/paste the 3 sections from the example into the newly created 3 separate files. Then replace the code inside the viewstack with calls to your newly created 3 files based on the VBox
kenneth