Dynamicly create text?
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
- MJKram
-
MJKram
- Member since: May. 30, 2005
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
_root.createTextField("textname", depth , x , y , width , height);
textname.text = "message here";
eg.
_root.createTextField("score", 1 , 150 ,50 , 125 , 50);
score.text = "SCORE: "+sc;
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
Thanks!!
But how would I give it a font, font size, color, boldness, etc.?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
MovieClip.createTextField()
Availability
Flash Player 6.
Usage
my_mc.createTextField(instanceName, depth, x, y, width, height)
Parameters
instanceName A string that identifies the instance name of the new text field.
depth A positive integer that specifies the depth of the new text field.
x An integer that specifies the x coordinate of the new text field.
y An integer that specifies the y coordinate of the new text field.
width A positive integer that specifies the width of the new text field.
height A positive integer that specifies the height of the new text field.
Returns
Nothing.
Description
Method; creates a new, empty text field as a child of the movie clip specified by my_mc. You can use createTextField() to create text fields while a SWF file plays. The text field is positioned at (x, y) with dimensions width by height. The x and y parameters are relative to the container movie clip; these parameters correspond to the _x and _y properties of the text field. The width and height parameters correspond to the _width and _height properties of the text field.
The default properties of a text field are as follows:
type = "dynamic"
border = false
background = false
password = false
multiline = false
html = false
embedFonts = false
variable = null
maxChars = null
A text field created with createTextField() receives the following default TextFormat object:
font = "Times New Roman"
size = 12
textColor = 0x000000
bold = false
italic = false
underline = false
url = ""
target = ""
align = "left"
leftMargin = 0
rightMargin = 0
indent = 0
leading = 0
bullet = false
tabStops = [] (empty array)
Example
The following example creates a text field with a width of 300, a height of 100, an x coordinate of 100, a y coordinate of 100, no border, red, and underlined text.
_root.createTextField("mytext",1,100,100,3
00,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;
myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
myformat.underline = true;
mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);
See also
TextFormat class
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
How do I make the text in the text box centered?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 7/23/05 07:24 PM, jeremysfilms wrote: How do I make the text in the text box centered?
myformat = new TextFormat();
myformat.align="center"
mytext.text = "this is my first test field object text";
mytext.setTextFormat(myformat);
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
Is there any way to do it without using the textFormat object? Like just saying:
myText.align="center"??
Or do I need to use textFormat?
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
At 7/23/05 07:30 PM, jeremysfilms wrote: Is there any way to do it without using the textFormat object? Like just saying:
myText.align="center"??
Or do I need to use textFormat?
I've found that some of the textformat stuff you can get away with just stating (eg.textname.text="Radish";), but some of the stuff requires you to actually create the newTextFormat and apply it to your textbox with .setTextFormat(jhlfkksd)
I think 'align' is one of the ones you have to declare with a newTextFormat


