Home arrow Flash arrow Page 2 - XML Sockets in Flash
FLASH

XML Sockets in Flash


The purpose of this tutorial is to familiarize readers with the XMLSocket object in Flash, it's methods and properties. Teach the reader the more common methods of using the XMLSocket object, and then open the reader up to the possibilities allowed by the XMLSocket Object.

Author Info:
By: Richard Lyman
Rating: 4 stars4 stars4 stars4 stars4 stars / 30
April 02, 2002
TABLE OF CONTENTS:
  1. · XML Sockets in Flash
  2. · Methods and Properties
  3. · Common Utilizations
  4. · Possibilities
  5. · Summary

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
XML Sockets in Flash - Methods and Properties
(Page 2 of 5 )

I'll enumerate the different methods and properties that this object contains, and then explain common coding practices.

close() - This method allows you to cleanly terminate an open socket from the client's end of communication.

connect() - This method allows you to connect to a server running a socket server that is able to interpret the EOL character that is currently standard for Flash sockets (the ASCII null character, or '\0'). It will also eventually invoke the onConnect event-handler. This method accepts two parameters: a string as the URL of the server to connect to, and an integer as the port that the socket server is waiting on.

send() - This method allows you to send a string of characters through the socket connection. While the string is usually in XML format it does not have to be. This string can either be constructed using the XML object within Flash, or manually if size permits. Flash will also automatically append the terminating null character for you.

onConnect() - This event-handler is invoked either on success or failure for the connection attempt. It will return a Boolean based on the connections status (not to be confused with the 'status' property of a parsed XML object).

onXML() - This event-handler is invoked upon receipt of a null character. When this event is triggered the data that was received since the last null character has already been parsed, and placed into a hierarchy that you can use to retrieve the data – again using the XML object in Flash.

onData() - This event is similar to the onXML event, but it is triggered before any parsing. This allows for manual parsing or custom string handling (which can be quite useful as we’ll see near the end of this article).

onClose() - This event is not as intuitive as it might seem. It is triggered when the server terminates the connection - not when the client terminates. This is generally used to handle an unexpected disconnection from the server.
blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials