Use XMLSocket to monitor the production system in flash (2-4)
Source: Internet
Author: User
2. skills 3. TextField text field objects before TextField objects are involved, we must first understand that there are three types of texts in Flash: 1) static text (StaticText) the content and style are both determined by creation. in FlashMX, there can be vertical 2. skills first
3. TextField text field object
Before adding a TextField object, we must first understand that there are three types of text in Flash:
1) Static Text)
The content and style are determined by creation. in Flash MX, there can be vertical static text, which is set in the Flash property checker (about the static text, see the author's other article "Flash Text ").
2) Dynamic Text)
Is an instance of the TextField object. you can set a unique instance name for it in the Flash property checker, then you can apply the instance name to apply the corresponding methods and attributes to change the content and style of dynamic text.
In the case that XMLSocket is used to promptly monitor the production system using the Web method, the dynamic text is used to display different messages sent by the server in different colors:
MyTextFormat. color = '0xff0000 ';
Txt. setNewTextFormat (myTextFormat );
Txt. replaceSel ('error -- 'e. attributes. text '--'
E. attributes. time newline );
} Else if (e. attributes. type = 'normal '){
MyTextFormat. color = '0x0000ff ';
Txt. setNewTextFormat (myTextFormat );
Txt. replaceSel ('normal -- 'e. attributes. text '--'
E. attributes. time newline );
}
}
}
The preceding statement is part of the onXML event processing function of the XMLSocket object. The first statement in the function gets the first node of the XML document. assume that the data sent by the server is
Next, a nested if statement is used to determine the type of the node represented by variable e. For example, if it is of the 'error' type, use myTextFormat (an example of TextFormat text style object ), this information is displayed in red. for example, if it is of the 'error' type, the information is displayed in blue using myTextFormat. in actual situations, you can, as needed, define any information type.
The variable txt represents a dynamic text object. every time you receive the data, you call the replaceSel () method of the TextField object to insert the corresponding data into the top row of the text box. Why is it the top line? This is the role of the Selection. setSelection (0, 0) statement, which positions the cursor position to the first position in the first line. Newline is a constant in Flash, representing a line feed.
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service