User Guide

Using Flash and Other Interactive Media Types 305
To access a property of the object, such as the arrays length, you only need to refer to the
property as a property of the object reference you created:
put myNewFlashObject.length
-- 3
To access a part of the object, such as the value of the third item in the array, use the following
syntax:
put myNewFlashObject[2]
-- "banana"
Note: The items in an ActionScript array are numbered beginning with zero, while the items in a Lingo list are
numbered beginning with one. Be sure to use the correct number when referring to items in arrays or lists.
To access a method of the object, use the same syntax and specify the method name after the
object reference:
myNewFlashObject.sort()
For more information about the types of objects supported by Flash and the methods and
properties used to control them, see the Flash documentation.
Setting callbacks for Flash objects
Some kinds of Flash objects generate events that need to be routed to an appropriate Lingo
handler. For example, a Flash Communication Server connection object generates an event each
time an incoming message is received from the server. You can tell Lingo to route events like this
to a specific handler in a specific Lingo script object by using the
setCallback() command.
To set up a callback for an event from a Flash object, use Lingo similar to this:
myConnection = sprite(1).newObject("NetConnection")
sprite(1).setCallback(myConnection, "onStatus", #dirOnStatusHandler, me)
In the first line of this example, a new netConnection object is created along with a reference to
it named
myConnection. The second line tells Lingo to call the handler named
dirOnStatusHandler whenever the myConnection object generates an onStatus event. The
argument me indicates that the handler is located in the same script object that the
setCallback() command is being issued in. In this case that script object is attached to sprite 1.
The callback handler could look like the following:
on dirOnStatusHandler (me, aInfoObject)
if (aInfoObject[#level] = "error") then
member("chat input").text = "Error sending last message."
end if
end