Table of Contents

XML.onData( ) Event Handler Flash 5

executed when external XML source code finishes loading but has not yet been parsed
xmlDoc.onData(src);

Arguments

src

A string containing the loaded XML source code.

Description

The onData( ) handler executes automatically whenever raw XML source has finished loading into xmlDoc due to an earlier load( ) or sendAndLoad( ) invocation. The specified xmlDoc must be the top-level node in an XML object hierarchy (i.e., an instance of the XML class, not the XMLnode class).

By default, onData( ) has the following behavior:

The onData( ) handler can be assigned a custom callback function to intercept raw XML source code before ActionScript has a chance to parse it. Under certain circumstances, manipulating raw XML source manually may offer improved performance over ActionScript's built-in parsing, particularly in Flash Player 5. In Flash Player 6, the native XML parsing usually is faster than custom ActionScript routines.

Example

The following example shows how to display raw loaded XML source while preventing it from being parsed by ActionScript:

myDoc = new XML();
myDoc.onData = function (src) {
  trace("Here's the source: \n" + src);
};
myDoc.load("book.xml");

The following example intercepts and displays raw loaded XML source, but it also performs onData( )'s normal duties:

myDoc = new XML();
myDoc.onData = function (src) {
  trace("Here's the source: \n" + src);
  if (src =  = undefined) {
    this.onLoad(false);
  } else {
    this.parseXML(src);
    this.loaded = true;
    this.onLoad(true);
  }
};
myDoc.onLoad = function (success) {
  trace("Here's the parsed XML: " + this);
  trace("Load succeeded? " + success);
};
myDoc.load("book.xml");

See Also

XML.onLoad( ), XML.load( )


Table of Contents