Equivalent of Flex DataBinding using Pure Actionscript

Posted by Joshua on Stack Overflow See other posts from Stack Overflow or by Joshua
Published on 2010-06-14T05:13:20Z Indexed on 2010/06/14 5:22 UTC
Read the original article Hit count: 451

What is the ActionScript equivalent of this?

<mx:Label text="Hello {MyVar} World!"/>

In ActionScript it would need it to look something like this:

var StringToBind="Hello {MyVar} World!"; // I've Written It This Way Because I Don't Know The Exact Text To Be Bound At Design Time.
[Bindable]
var MyVar:String='Flex';
var Lab:Label=new Label();
Lab.text=???
...
SomeContainer.addChild(Lab);

How can I accomplish this kind of "Dynamic" binding... Where I don't know the value of "StringToBind" until runtime? For the purposes of this question we can assume that I do know that any variable mentioned in "StringToBind", is guaranteed to exist at runtime.

I already realize there are much more straightforward ways to accomplish this exact thing STATICALLY, and using only Flex. It's important for my project though that I understand how this could be accomplished using purely ActionScript.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash