you created a text field, but you probably didn't add it to any display
objects.
import flash.display.Sprite;
import flash.text.TextField;
var myTextField:TextField = new Textfield();
myTextField.text = txt;
addChild( myTextField);
myTextField.x = X;
myTextField.y = Y
The important bit you gotta realize is that the addChild method (in this
case) is using whatever the scope of the code is to add to the stage.
So the scope, or "this" would need to extend from a display object (a
movieclip, sprite, stage, etc).
You could also import the stage class and do stage.addChild(myTextField).
John Lawrence wrote:
Hey folks,
Im trying to learn how to set a TextField on the stage dynamically
with ActionScript 3
something like
public function addText(txtname:String, txt:String, X:int, Y:int,
format:TextFormat):void {
//using array notation for a new variable does NOT WORK
var [txtname]:TextField = new TextField();
....
}
cheers!
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com