Question

[This will take you to an image of my project so that you may see the code because I haven't been a member long enough to post one. :]1

This is a project I'm working on for a simple demo tutorial application in Flex. I am using mxml pages. You can see to the left that I will have my main application and then other mxml files (In the Examples Package) as the examples that will be loaded into the main application mxml. How can I dynamically pull the value from the object in the list to load the child mxml file into the container that I have further down in the application?

Was it helpful?

Solution

I'm unclear exactly what you're trying to do; but based on the code snippet I see two possibilities.

First, if all of your separate samples are compiled into individual SWFs; then you can load them using the SWFLoader. Based on the XML in your code snippet, it seems to reference separate SWFs.

If you're code samples are just compiled into the main application, then you can use a ViewStack and switch the index of the ViewStack depending on the sample you want to show. Conceptually something like this:

<mx:ViewStack id="sampleViewStack">
  <myComps:Sample1 />
  <myComps:Sample2 />
  <myComps:Sample3 />
</mx:ViewStack>

To show sample one, just do this in ActionScript:

sampleViewStack.selectedIndex = 0;

To show sample 2, do this:

sampleViewStack.selectedIndex = 2;

And so on...

However, if you want to compile each sample on the fly and display it in your main application you'll have a much harder job.


If I understand correctly, You said you're having a hard time accessing properties on the object that are in the lists dataProvider. Based on your screenshot of the code, it looks like your dataProvider is made up of generic objects. To access the label or value properties on those objects; you'll; have to do this:

list.selectedItem['label']
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top