For two days, I'd like to design a as3+xml news list (http://www.towncool.com/Samples/1/index.html) for the Tang cool. But has been TextField plus monitoring and textformat problems affect, very tangled. But finally the problem is solved. Two basic problems were found through multiple tests:
First, the TextFormat must be set after the Textfield.text assignment. Otherwise, the TextFormat style call does not go in. This is especially true for Chinese. However, in practical applications, the text class is usually set, and then the value is assigned when called. In this way, the role of TextFormat is lost. Therefore, the emphasis is given to text assignment, and then set TextFormat.
Second, the original thought TextField belongs to the Interactiveobjec class, can interact, can directly trigger the TextEvent monitoring event, in fact, it is necessary to set the XML href= "Event:mytext" before listening. I understand: The text can not go to the event, you need to write the name of "events:", in addition, TextField need. HTMLText form assignment. Set the TextField content assignment form and XML, you can add monitoring.
Here are some common control methods for you to learn:
TextField The following example provides three ways to control text display, as to which method to use in the actual application, to see everyone's hobby ~ ~:
Program Code Program code
HTMLText Method:
var tmp1_text:textfield=new TextField ();
tmp1_text.x=10;
tmp1_text.y=10;
tmp1_text.width=200;
tmp1_text.height=60;
Tmp1_text.htmltext = "<font color= ' #0033FF ' > Blue </font><font color= ' #ff0000 ' > Red </font>< Font color= ' #FF6600 ' > Orange </font> ' + ' \ n ' +
"<font color= ' #666666 ' size= ' one ' > ' Gray </font><font color= ' #000000 ' > Black </font><b>< Font color= ' #33CC00 ' size= ' > Green </font></b> ' + ' \ n ';
AddChild (Tmp1_text);
//----------------------------------------------------------------------------------
TextFormat Method:
var tmp2_text:textfield=new TextField ();
var format1:textformat=new TextFormat ();
var format2:textformat=new TextFormat ();
//----------------------------------------------------------------------------------
Htmltext+css Method:
var tmp3_text:textfield=new TextField ();
var style:stylesheet = new StyleSheet ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.