Use XMLSocket to monitor the production system in flash (3-4)

Source: Internet
Author: User
4) select the UI layer, select the text tool in the toolbox, and set the property ShowBorderAroundText to true, the text type to DynamicText, and the text to Multiline ), draw a picture in the upper half of Stage (Stage) 4) select the UI layer and select the text tool in the toolbox, in the property checker, set the property Show Border Around Text to true, the Text type to Dynamic Text (Dynamic Text), and the Text to Multiline (Multiline). in the Stage) the upper part draws a large text area and sets the actual name as txt. 3. now, I have noticed that the txt text domain has a border and a white background. I personally don't like white. can I change the landscape of the text domain?

Of course, we can say that all the methods we can see in Flash MX can be used to change the background of the txt text field to # BBBBCC color, in the [initialization of objects during Flash creation] section of the program, enter the following statement:

Txt. backgroundColor = '0xbbbbcc ';

You can preview the txt text field by using the Control-> Test Movie menu (or Ctrl Enter shortcut key.

5) open the Componets panel through the Window-> Componets menu, select the ScrollBar component, and drag it to the txt text field on the stage. when you open the mouse, the two will automatically join. In the property checker, the Target TextField attribute of the ScrollBar component is txt, and a unique instance name is assigned to the ScrollBar component, such as scrollbar. when the information is displayed on a full screen, you need to rotate the bar to view the previous information, so you need to set the scrollbar at the beginning of the program to activate it. in the [initialization of the object during Flash creation] part of the program, take the following statement:

Scrollbar. setScrollProperties (10, 10, 20 );

6) select a Text tool from the toolbox and set the property Show Border Around Text to true and the Text type to Input Text in the property checker) the text is Single Line (Single Line), and two text fields are drawn from the bottom of the txt text area on the Stage, and the real name is distinguished as txtHost and txtPort:



In addition, in the property checker, set the Maximum Characters (Maximum length) of txtPort to 5 (because the Maximum number of ports is 65535), and set txtPort to only enter numbers, we can set the limit on the Character button in the property checker. we can set the limit at runtime using the ActionScript here (or in the property checker ), in the [initialization of objects during Flash creation] section of the program, run the following statement:

TxtPort. restrict = '0-9 ';
TxtPort. onChanged = txtPort_onChanged;

Set txtHost to "Default Host" and txtPort to "6666 ". At the same time, because the user typed the wrong number of ports in txtPort, the background of txtPort will change to red (for details, refer to the content in the Input box Text (Input Text ), when you press again, the background color turns back to the original white, which is implemented in the txtPort onChanged event. 7) from the Componets panel, select two PushButton components to the right of the txt text field on the stage. the degree is the same as the text of the first two input boxes.

The instance name of the first PushButton button is btnConnect, the Label is set to Connect, and the Click Handler (Click the Event Processing function) is set to btnConnect_onClick. The instance name of the first PushButton Button is set to btnClear, the Label is set to Clear, and the event processing function is set to btnClear_onClick. 4:




After completing the above steps, we have established a real user interface for the Flash client. Now we will create and initialize the corresponding object in the second part of the program [initialization of the object during Flash Runtime:


MyTextFormat = new TextFormat ();

Socket = new XMLSocket ();
Socket. onConnect = myOnConnect;
Socket. onXML = myOnXML;
Socket. onClose = myOnClose;

In the preceding statement, the first statement is inherently a TextFormat (Text style object) instance myTextFormat to display different types of data in different colors (see the previous Dynamic Text (Dynamic Text) ). Next, an XMLSocket instance socket is created, and the processing functions for onConnect, onXML, and onClose events are distinguished.

At the end of the following, we only need to write the event processing functions for various objects. as the second part of this article has already made some specific preparations for the related techniques, you can also refer to the program source code included in this article. in order to save space, this part will not be further introduced. if you are in practical application, with the title you can send me E_mail: yz2yz@etang.com.

Now that the program has been completed, start the server imitation program on your Web server, Connect to the corresponding page containing the Flash client through a browser, and click the Connect button. if there are no other accidents, you will see that the client is running normally. For the convenience of testing, you can start the server imitation program on the local machine, and then open it through a separate Flash Player 6. in txtHost, type "127.0.0.1 ", this saves you the trouble of setting up Web servers. Wish you success!

   Click to download source code


Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.