How to load flex components using XML. The scenario is simple as like this, i need three buttons to appear in my panel, but the option true or false whether to appear should be in xml.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re not exactly clear in your question, so I’ll answer in two ways:
1. You need to have an external MXML
In this case, you need to compile the XML file with mxmlc.exe (or just rename it to .mxml and include it in Flex Builder) and use the SWFLoader component to access the file. I don’t have a lot of experience with SWFLoader, so I’ll leave it up to you to look it up.
2. You need to set the properties of the components through an external XML
Create a HTTPService, assign an ID to it, and use the url property to point it to your XML file. Do not assign a result format. Then, use the result event and point to a function that will execute when your XML is done loading. It should look like this:
Lets say myXml looks like this:
This is what your function Foo should look like. It will be executed when the HTTPServices finishes loading myXml.xml.
This function gets the result of service and assigns various buttons some properties as defined in the XML. Alternatively, you can also use service.lastResult to access the most recent result from anywhere in the script.
Hope this helps!