Flash through the Xmlsocket Monitoring production system (3-2)

Source: Internet
Author: User
Tags add object connect socket client
xml| Monitoring

4 Select the UI layer, select the Text tool in the toolbox, and set the properties in the property Inspector show Border Around text is true, the text type is dynamic text, and text is multiline (multiple lines), in stage The upper part of the (stage) draws a large text area and sets its instance name to TXT. As figure three, now note that the TXT text field has a border and a white background, I personally do not like white, can change the background color of the text field?

Of course, you can say that in Flash MX, you can see that there are ways to change, we will be the background of txt text field into #BBBBCC颜色吧, please add the following statement in the program's [initialization of object in Flash Authoring] section:

Txt.backgroundcolor = "0XBBBBCC";

With the control-> Test Movie menu (or Ctrl + Enter shortcut) Preview, you will see that the background of the TXT text field has changed to the desired color.

5 through the Window-> componets menu, open the Componets (component) Panel, select the ScrollBar component onto the stage on the TXT text field, when the mouse release, the two will automatically combine, as shown in Figure five. To the property inspector, the target TextField property of the scrollbar component is txt, and a unique instance name, such as ScrollBar, is given to the scrollbar component, as it is necessary to view past information through the scroll bar when the information is displayed full screen. So you need to set the scrollbar at the beginning of the program to activate it, and add the following statement to the program's [initialization of objects in Flash authoring] section:

Scrollbar.setscrollproperties (10, 10, 20);

6 Select the Text tool from the toolbox and set the property in the property Inspector show Border Around text is true, the text type is input text (input box text), text is single line (Single-line), On the stage (stage), below the TXT text area, draw two text fields on the left, and set their instance names to Txthost and Txtport, as shown in Figure three:

-->

In addition, in the property inspector, set the maximum Characters (maximum length) of Txtport to 5 (because the maximum number of ports is 65535), the setting Txtport can only enter a number, we can set the limit on the character button in the property inspector. We use ActionScript to set up at runtime (or set in the property inspector), and add the following statement to the program's [initialization of objects in Flash authoring] section:

Txtport.restrict = "0-9";
txtport.onchanged = txtport_onchanged;

And the content of the set Txthost is "Default Host" and the content of Txtport is "6666". Also, because the user types the wrong number of ports in the Txtport, the background of the txtport will be red (see Introduction to the previous input text), and the background color will change back to the original white when the user types it again, which Txtport in the OnChanged event. 7 from the Componets (component) Panel, select two Pushbutton components to drag to the lower-right position of the TXT text field on the stage, up to the previous two input box text.

The instance name of the first Pushbutton button is set to Btnconnect, the label (label) is set to Connect, click Handler (clicking the event handler function) is set to Btnconnect_onclick. The instance name of the first Pushbutton button is set to Btnclear, the label (label) is set to clear, and the event handler function is set to Btnclear_onclick, as shown in Figure four:




By completing the above steps, we have established the user interface for the Flash client. Now we're going to create and initialize the corresponding object in the second part of the program [initialization of the Flash runtime object]:


Mytextformat = new TextFormat ();

Socket = new Xmlsocket ();
Socket.onconnect = Myonconnect;
Socket.onxml = Myonxml;
Socket.onclose = Myonclose;

In the above statement, the first statement generates a TextFormat (Text style object) instance Mytextformat to achieve the purpose of displaying different types of data in different colors (see the previous dynamic text introduction). It then generates a Xmlsocket object instance socket and sets its handler function for OnConnect, Onxml, and OnClose events, respectively.

The following is where we end up with event handlers for various objects, because in the second part of this article, the relevant technology has been introduced in considerable detail, and you can refer to the source of the program included in this article, in order to save space, this part will no longer be introduced, if you are in actual use, You can send me a e_mail:yz2yz@etang.com if you have any questions.

Now that the program is done, start the server emulator on your Web servers, then connect to the page that contains the Flash client through the browser, click the Connect button, and if there are no other surprises, you will see the client running normally. If the test is convenient, you can start the server-side emulator on the local machine, then open it with a separate flash Player 6来 and type "127.0.0.1" in Txthost, which will save you the hassle of setting up your Web servers. I wish you well.



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.