Flash
  Home arrow Flash arrow Page 6 - Working with external data in Flash
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Working with external data in Flash
By: Adi Reddy Mora
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 22
    2005-05-11

    Table of Contents:
  • Working with external data in Flash
  • getURL(), loadVariables(),loadVariablesNum(), loadMovie(), and loadMovieNum() methods
  • LoadVars Class
  • MovieClipLoader class
  • XML Class
  • XMLSocket Class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with external data in Flash - XMLSocket Class


    (Page 6 of 6 )

    XMLSocket class in ActionScript lets you open a continuous connection with a server. A socket connection lets the server publish, or  push, information to the client as soon as that information is available. The data is sent over the socket connection as one string and should be formatted as XML. You can use the XML class to structure the data.

    The methods of XMLSocket Class create and use TCP/IP socket connections to send and load information as XML.

    You can use the connect()and send()methods of the XMLSocket class to transfer XML to and from a server over a socket connection. The connect()method establishes a socket connection with a Web server port. The send()method passes an XML object to the server specified in the socket connection.

    Now let us see an example that shows how to use the XMLSocket Class.

    Example:

    // Create XMLSocket object
    
    var sample_socket:XMLSocket = new XMLSocket();
    
    // Connects to localhost server with port number 1024
    
    sample_socket.connect("localhost", 1024);
    
    // Displays connection status information
    
    sample_socket.onConnect = function(status) {
    
     if (status) {
    
       conn_txt.text = "connection successful";
    
     } else {
    
       conn_txt.text = "no connection made";
    
     }
    
    };
    
    // Function that creates data to send it to the server using
    
    send() method
    function sendData() {
    
     var data:XML = new XML();
    
     var send = data.createElement("user");
    
     send.attributes.id = "asp123";
    
     data.appendChild(send);
    
     sample_socket.send(data);
    
    }
    
    // onData event handler function to track the data returned from
    
    socket connection and perform actions based on that data
    sample_socket.onData = function(msg:String):Void {
    
     trace(msg);
    

    };

    Note:The XMLSocket.connect()method can connect only to TCP port numbers greater than or equal to 1024. Port numbers below 1024 are often used by system services such as FTP, Telnet, and HTTP, so XMLSocket objects are barred from these ports for security reasons.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    FLASH ARTICLES

    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT