Using Flash and Other Interactive Media Types
305
•
To access a property of the object, such as the array’s 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
Содержание DIRECTOR MX-USING DIRECTOR MX
Страница 1: ...Using Director MX Macromedia Director MX...
Страница 12: ...Contents 12...
Страница 156: ...Chapter 4 156...
Страница 202: ...Chapter 6 202...
Страница 244: ...Chapter 7 244...
Страница 292: ...Chapter 10 292...
Страница 330: ...Chapter 12 330...
Страница 356: ...Chapter 13 356...
Страница 372: ...Chapter 14 372...
Страница 442: ...Chapter 16 442...
Страница 472: ...Chapter 18 472...
Страница 520: ...Chapter 19 520...
Страница 536: ...Chapter 20 536...
Страница 562: ...Chapter 23 562...
Страница 566: ...Chapter 24 566...
Страница 602: ...Chapter 27 602...