Welcome, Guest
  • Author Topic: AMF vs. XML and other acronyms  (Read 4162 times)

    Ron Chambers

    • Server what's that
    • *
    • Posts: 2
      • View Profile
      • Email
    AMF vs. XML and other acronyms
    « on: 01/24/03, 17:46 »
    I'm new to Flash/ActionScript (2 days), background is in PHP/MySQL (3 years).  I've been trying to understand all the ways to get data from PHP to Flash MX and it's come down to a few questions.  

    1) XML Question:  When sending XML from PHP to the xml object in Flash MX will I need to write action script to parse (loop) through the xml and define arrays of all the parent/child nodes?  Such as (psuedo code): while (nodes exist) { array[] = xml.child value; xml.get next child; }   Is there a function in action script for Flash MX that automatically populates a multidimensional array or hash with all the xml nodes?  Is this what XMLNitro.as is intended to do?

    2) AMF:  I'm concluding that the amfdata code from Musicman and now Justin, that does what flash remoting does, is going to be the best option.  When compared to XML it should transmit faster because it's binary and it doesn't require all the tags that xml does and it doesn't require much in Action Script to "parse" out the variables.  Is this correct?

    After all the reading I could do, I think all the ways to get data to Flash have been boiled down to those that where covered by Musicman (loadvars, using Ming to write a swf file with data in the properties, and the amfdata class) along with XML.  As for the other acronyms SOAP/WDSL/XML-RCP/NuSOAP these work well when dealing with other web services but for just straight PHP to flash communication the best option has to be the amfdata class.

    Thanks - Any thoughts?

    Ron Chambers

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re:AMF vs. XML and other acronyms
    « Reply #1 on: 01/25/03, 05:40 »
    About XML: you allways need to parse the XML object through the specific methods like firstChild, nodeType, nextSibling and so on. The XML.parseXML() method just create an XML object from a string argument. That's the reason because you even need a parse rotine to walk through the XML objects, and always need an extra effort to send/receive data in XML format. For locally exchange (that's sharing data between my database or my own server-side services) I do not use XML. Anyway, to share data with other services or sites, is a good choice. Also there are alot of components that use XML as source, because as general purpose components, XML is a clear source of data.
    The xmlnitro is a base class writed by Branden Hall intended to faster the perfomance of XML parsing in Flash 5, and also to add an important functionality that is built in in MX: ignoreWhite. The perfomance of XML in Flash 5 is really bad, but in Flash MX becomes highly better.

    Quote

    // XMLnitro v 2.1 - Branden J. Hall - Fig Leaf Software - October 1, 2001
    //--------------------------------------------------
    // This file simply replaces the built-in parseXML
    // method.  In doing so it increases the speed of
    // XML parsing 70-120% (dependent on file size).
    // In addition, the ignoreWhite property now works
    // in all versions of the Flash 5 plugin and no
    // just the R41/42 versions. In order to do such
    // this parser removes all text from mixed content
    // nodes (i.e. nodes that contain both child nodes
    // and child text nodes). This code is Flash 5
    // specific so it makes sure that the user has only
    // a Flash 5 plugin.
    //--------------------------------------------------


    About amfdata, I think also is the best choice to share complex data, and faster since it uses a native Flash format that don't require a parser routine. Tipically queryng a database or calling services are good choices. Anyway, to load a couple of variables, the LoadVars object is fine.

    Jorge