PDA

View Full Version : Place Dynamic Text?



Phaaze
June 17th, 2008, 08:12 PM
How can I create and place dynamic text via actionscript? All I could find online was creating a text field (form component)... However, I just want a dynamic text box (not a form component) that I can use to keep score in a game. I'm trying to learn things in AS3, therefore, please avoid any aswers telling me to simply place one on the stage... (Unless thats the only way possible, of which I doubt. Especially since, to my understanding, flash converts all stage elements into actionscript when rendered.)

Thanks,
- Phaaze

congyaan
June 17th, 2008, 11:35 PM
var tempText:TextField = new TextField();
tempText.text = "we are friends";
tempText.x = 100;
tempText.y = 100;
addChild(tempText);

Phaaze
June 18th, 2008, 06:35 AM
Hey, thanks for the help. Could you tell me how I can format the text?

I tried the following but it didn't work.

var tempText:TextField = new TextField();
tempText.text = "we are friends";
tempText.x = 100;
tempText.y = 100;
tempText.y = 100;
addChild(tempText);
var myFormat:TextFormat = new TextFormat();
myFormat.color = 0xAA0000;
myFormat.size = 24;
myFormat.italic = true;
tempText.setTextFormat(myFormat);


Thanks again,
- Phaaze

Phaaze
June 18th, 2008, 06:59 AM
PROBLEM SOLVED

I needed to import flash.text.*;

Thanks again,
- Phaaze