hello :)
to attach a Sprite, MovieClip, TextField, ...., DisplayObject in a
DisplayObjectContainer you must use the addChild method :
Read the examples in my article about TextField in AS3 (the article is in
french but the code is in AS3 ;))
http://www.ekameleon.net/blog/index.php?2006/07/18/38--as3-textfield-les-bases
For me the best solution to use a custome TextField is the implementation of
a custom class :
package
{
import flash.display.Sprite ;
class MainApplication extends Sprite
{
// ----o Constructor
public function MainApplication ()
{
var tf:MyField = new MyField(10, 10, 120, 20) ;
tf.text = "Hello World" ;
addChild ( tf ) ;
}
}
}
import flash.text.TextField ;
class MyField extends TextField
{
// ----o Constructor
public function MyField( x:Number=0, y:Number= 0, w:Number=0, h:Number=0)
{
this.x = x ;
this.y = y ;
height = h ;
width = w ;
selectable = false ;
textColor = 0xFF0000 ;
border = true ;
borderColor = 0xFFFFFF ;
}
}
EKA+ :)
2006/12/29, John Lawrence <[EMAIL PROTECTED]>:
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