Summary of classes used in AS3.0 for network communication

Source: Internet
Author: User
Tags live chat

0 Reviews

1.Loader

The Loader class can be used to load SWF files or images (JPG, PNG, or GIF) files. It can only be these objects.

Network protocol Basics: Http/rtmp

Load method Prototype: Loader.load (request:urlrequest, context:loadercontext = null): void

2.URLLoader

The URLLoader class downloads data from a URL in the form of text, binary data, or URL-encoded variables. It is useful for downloading text files, XML, or other information that is used for dynamic data-driven applications.

The URLLoader object downloads all data from the URL before it is used in ActionScript. It sends notifications about the progress of the download, through bytesLoaded and bytesTotal properties, and scheduled events, to monitor the download progress.

Network protocol Basics: Http/rtmp

Load method Prototype: Urlloader.load (request:urlrequest): void

3.URLStream

The URLStream class provides low-level access to the download URL. Data is downloaded, it can then be used for ActionScript, which will need to wait for the entire file to download when using URLLoader. And the URLStream class also allows you to close the stream before completing the download. The contents of the downloaded file are provided as raw binary data.

Network protocol Basics: Http/rtmp

Load method Prototype: Urlstream.load (request:urlrequest): void

4.NetStream

The NetStream class opens a one-way streaming connection between Flash Player and Flash Media Server or between Flash Player and the local file system. The NetStream object is a channel in the Netconnection object. This channel can use NetStream.publish() a publishing stream, or you can use NetStream.play() a subscription-published stream and receive data. You can publish or play real-time data and previously recorded data. You can also use the NetStream object to send text messages to all subscribed clients (see NetStream.send() methods).

Network protocol Basics: RTMP

Load method Prototype: NetStream (connection:netconnection)

5.Socket

The socket class enables ActionScript code to establish socket connections and read and write raw binary data. It is similar to XMLSocket, but does not specify the data format to receive or transmit.

The Socket class is useful when used with a server that uses a binary protocol.

Network protocol Basics: TCP

Load method Prototype: Socket.connect (host:string, port:int): void

6.XMLSocket

The XMLSocket class implements a client socket, which allows the computer running Flash Player to communicate with a server computer identified by an IP address or domain name. The XMLSocket class is useful for client/server applications that require short latency, such as live chat systems. Traditional HTTP-based chat Solutions frequently poll the server and use HTTP requests to download new messages. In contrast, the XMLSocket chat solution maintains an open connection to the server, which allows the server to instantly send incoming messages without requiring the client to make a request. To use the XMLSocket class, the server computer must run a daemon that recognizes the protocols that are used by the XMLSocket class. The following list illustrates the protocol:

    • The XML message is sent through a full-duplex TCP/IP streaming socket connection.
    • Each XML message is a complete XML document, ending with a 0 (0) byte.
    • There is no limit to the number of XML messages sent and received through the XMLSocket connection.

XMLSocket.connect()Method can only connect to a TCP port with a port number greater than or equal to 1024. One consequence of this limitation is that the server daemon that communicates with the XMLSocket object must also be assigned a port number greater than or equal to 1024. Ports with a port number less than 1024 are typically used for system services such as FTP, Telnet, and HTTP, so the XMLSocket object is prohibited from using these ports for security reasons. This limitation of port numbers can reduce the likelihood of inappropriate access to and misuse of these resources.

Setting up the server to communicate with the XMLSocket object can be difficult. If your application does not require real-time interaction, use the URLLoader class instead of the XMLSocket class. To use the methods of the XMLSocket class, you must first new XMLSocket create a XMLSocket object using the constructor.

Network protocol Basics: TCP

Link Method prototype: Xmlsocket.connect (host:string, port:int): void

7.sendToURL method

Flash.net.sendToURL (Request:urlrequest)

8.navigateToURL method

Flash.net.navigateToURL (Request:urlrequest, Window:string=null)

Summary of classes used in AS3.0 for network communication

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.