User Guide
Using Flash objects in script 193
Sending XML Data from Flash to Director
You can send XML data from a Flash sprite or object to a script.
To send XML data from a Flash sprite or a global Flash object to a script:
1 On the Flash side, use the XMLobject.send ActionScript method.
The
XMLobject.send method has a URL and a targetWindow parameter.
2 On the Director side, include an on sendXML handler in your script to handle rhe XML data.
This handler takes the same parameters as the
XMLobject.send method, as follows:
on sendXML me, URL, targetWindow, xmlData
The xmlData parameter is the XML data contained in the original XMLObject. You can then
add script to the handler to process the XML data. A common action is to send the XML data
to the URL and await the response of the server located at the URL, as in this example:
on sendXML me, URL, targetWindow, xmlData
gotoNetPage(URL, targetWindow)
postNetText(URL, xmlData)
end
Using Flash objects in script
With Director, you can create Flash ActionScript objects and access all of their properties and
methods. You can create a wide variety of Flash objects, including arrays, dates, Booleans, XML
objects, and net connection objects for use with Macromedia Flash Communication Server MX.
If you have authored Flash content that contains ActionScript classes that generate custom
objects, you can access those objects in script as well. You can also create references to existing
ActionScript objects with the
getVariable() method. For more information about accessing
these objects, see “Using Lingo or JavaScript syntax to set and test Flash variables” on page 189.
When creating Flash objects, you can choose to create an object within a Flash sprite, or you can
create a global Flash object.
• To create a Flash object within a Flash sprite, you must have Flash content in the cast and a
Flash sprite on the Stage. Do not use a Flash cast member created with the method
new(#Flash), as this creates a Flash cast member shell, which contains no actual internal Flash
data. When you create a Flash object within a sprite, the object uses the same instance of the
Flash Player that Director loads when the Flash cast member appears on the Stage.
In your script, use the
newObject() method with a sprite reference. If the object you want to
create requires parameters, include them with the newObject() method:
myNewFlashObject = sprite(1).newObject("Array", "apple", "orange", "banana")
In this example, the specified sprite, sprite(1), is the Flash sprite. The object is an array.
(In Lingo, arrays are called lists.) The array contains three strings: "apple", "orange",
and
"banana".
• To create a global Flash object, use the newObject() method without a sprite reference. When
you do this, Director loads a special instance of the Flash Player into memory. This way, you
can use Flash objects without the need for a Flash cast member or sprite.
In your script, use the
newObject() method without a sprite reference:
myNewFlashObject = newObject("Array", "apple", "orange", "banana")