The MXMLLoader Class > Dynamic load MXML In Flex Builder 3
First of all I don’t really use flex to do flex stuff and I’m not a big fan of flex. But in my latest project I had to build with flex an interface witch would be always diferent (a dynamic interface). In the beginning we thought in parsing some type of XML, but if we are in flex why not parse MXML? I took a look over the internet and I only found MXMLLoader component v0.01, witch didn’t compile on flex builder 3 and was really in the beginning. So there it is, as XMMLLoader class for flex builder 3. You just have to instantiate the class with the mxml :
You can access objects by name:
Or by id:
And have access to component events like:
The class with an example:
May 14th, 2008 at 8:18 pm
Thank you for this article. I’ve been playing around with your example as well as the original component that you mention and I seem to be stuck. Are you familiar with the following error and where I may have gone wrong?
Thanks.
Error #1009:
[code]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MXMLLoader/createChildFromMXMLNode()[/Users/bealtr/Documents/Storage/Workspace/Flex Builder 3/MXML/src/MXMLLoader.as:111]
at MXMLLoader()[/Users/bealtr/Documents/Storage/Workspace/Flex Builder 3/MXML/src/MXMLLoader.as:41]
at MXML/init/onLoaded()[/Users/bealtr/Documents/Storage/Workspace/Flex Builder 3/MXML/src/MXML.mxml:25]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
[/code]
Here’s the code for my main mxml file. I’ve got both MXMLLoader.as and MXMLManifest.as in the source directory.
[code]
[/code]
May 14th, 2008 at 8:19 pm
Oops. I guess it filtered the code from my example is there a way for me to post you the code?
May 14th, 2008 at 8:21 pm
could you please post the files online so that we have a look?
It would generally seem as accessing it too early, or a typo, but do post the code
May 14th, 2008 at 10:14 pm
June 18th, 2008 at 3:00 pm
Is it possible to use DataGrid components? When trying I receive errors like:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::DataGrid@151c7851 to mx.core.Container.
and
ReferenceError: Error #1065: Variable is not defined.
What you are showing here seems very powerful!
June 18th, 2008 at 4:46 pm
June 18th, 2008 at 5:33 pm
That is what I was thinking…thank you for the verification and thank you for sharing your insight and example.