MACROMEDIA DIRECTOR MX-USING DIRECTOR MX Use Manual page 308

Table of Contents

Advertisement

Writing callback handlers
Now the callbacks are set up. In order for them to work, however, you must write the callback
handlers themselves. While the
in this example, the callback handlers must be outside the
handlers by themselves. In this example, the callback handlers are located in the same Lingo script
attached to the Flash sprite, just after the
The
event is generated each time the local connection object sends an outgoing
onStatus
message. The
myOnStatus
on myOnStatus (me, aInfoObject)
if (aInfoObject[#level] = "error") then
member("chat input").text = "Error sending last message."
else
member("chat output").text = member("chat output").text & RETURN & \
member("chat input").text
end if
end myOnStatus
Two arguments are passed with the
argument tells Lingo that the event was generated on the same Lingo script object that contains
the
handler. The
myOnStatus
information about the status of the message sending operation. The handler checks to see if the
argument contains an error. In this example, if there is an error, an error message is
aInfoObject
displayed in a chat input field. If no error occurs, a text output field is updated with the contents
of the chat input field. For more information about the Flash
Communication Server MX documentation.
The
allowDomain
message. This provides an opportunity for the
whether the message is coming from a trusted domain. The
must return
TRUE
The
myAllowDomain
on myAllowDomain (me, aSendingDomain)
if aSendingDomain = "myDomain.com" then
return TRUE
else
member("chat output").text = & RETURN & "Message received from \
unapproved domain."
return FALSE
end if
end myAllowDomain
The handler checks that the domain is the one that is expected, and returns TRUE if it is. If the
message comes from another domain, the return value is FALSE.
Once the
allowDomain
incoming message to the callback handler set up for the event. In this example, the subject of the
message is
incomingMessage
The
myIncomingMessage
on myIncomingMessage (me, aObject, aMessage)
member("chat output").text = & RETURN & aMessage
end myIncomingMessage
This handler simply appends the incoming message
308
Chapter 11
setCallback()
handler might look like this:
onStatus
aInfoObject
event is generated each time the local connection object receives an incoming
in order for the incoming message to be processed.
handler might look like this:
callback has returned
and the callback handler is
handler might look like the following:
commands are all inside a
beginSprite
handler.
beginSprite
event by the local connection object. The
argument contains a Flash array object containing
infoObject
callback handler to determine
myAllowDomain
myAllowDomain
, the local connection object forwards the
TRUE
myIncomingMessage
to the end of a chat output field.
aMessage
handler
beginSprite
handler because they are
me
, see the Flash
callback handler
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Director mx

Table of Contents