Monday, April 6, 2009

Displaying Text in Flash

Ok, so suppose you want to populate your swf with some data that you read in from an xml source. If you create a dynamic text box on your stage and call in mTexticle, then in your package (can only be done in a package) define a TextHolder:
public var mTextHolder:TextHolder;
public var mTextField:TextField;

Then you just need to do something weird like:
mTextField = mTextHolder.getChildByName("mTextField") as TextField;
mTextField.text = "Hello world" ;
addChild(mTextHolder);


*******

Ah, nevermind. Not that complicated. Suppose you create a dynamic text box in your app and it is called "coolTextThing". Then in your actionscript you can simply write:
coolTextThing.text = "Hello Senor";
Much easier...

0 comments: