Working with external text in Flex
Have you ever come across the situation where you just want to quickly put together a Flex-based interface with some text inside but don’t have a backend system in place yet? I certainly have.
What I did to make my life easier is simply create an ExternalText class that extends mx.controls.Text. It allows you to set a source attribute that points to the raw text you want to show and has an optional property called html to have it render as HTML or plain text.
<custom:ExternalText id="content" source="about.txt" html="true" width="350" height="350" />
You’re now able to easily test and layout your interface locally and when you’re ready to connect it up to some server side code its just a matter of changing the source attribute.
You can of course also hook up your navigation to simply update the source property of the ExternalText control and you’ve pretty much got yourself a functional application.
[flash]http://www.peterelst.com/blog/wp-content/uploads/2007/10/externaltext.swf,470,255[/flash]
I found this a rather nice little time saver for prototyping with Flex so wanted to share it with you all. Enjoy!
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Belgium License.
nice one, thanks for posting it.
Another way to achieve this may be with a resource bundle although that would require recompiling the app.
true Stefan, resource bundles are pretty cool — I just see this as a quick ‘n dirty way to hook up to an external text source, not something to be recommended for more complex data uses.