Name
XML.onLoad( ) Event Handler — executed when external XML data has been loaded and parsed
Availability
Flash 5
Synopsis
XMLdoc.onLoad(success)
Arguments
- success
A Boolean value indicating whether loading was successful (
true) or failed (false).
Description
The onLoad( ) handler of
XMLdoc is automatically executed whenever
an external XML file is loaded into XMLdoc
via the load( ) or sendAndLoad(
) methods. By default, the onLoad( )
handler of an XML document object is an empty function. To use
onLoad( ), we assign it a
callback handler
(i.e., a custom-made function). For example:
myDoc = new XML( );
myDoc.onLoad = handleLoad;
function handleLoad (success) {
// Process XML as desired here...
}We rely on onLoad( ) events to tell us when
it’s safe to process XMLdoc. If
onLoad( ) is triggered, we know that the loading
and parsing of external XML data have completed, so we may safely
access that loaded content. The onLoad( )
handler, hence, alleviates the need to write preloading code to wait
for data to arrive after the invocation of an XML load(
) function. For example, in the following code we load an
XML document, and then we wait for our custom handleLoad(
) function to be automatically executed when loading
completes. If loading was successful, we process our XML content with
the display( ) function. Otherwise, we show an
error message by executing the display( )
function. (The displayProduct( ) and
displayError( ) functions are custom functions that you’ve presumably written to display ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access