User Guide

Using the Flash local connection object 197
The onStatus event is generated each time the local connection object sends an outgoing
message. The
myOnStatus handler might look like this:
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 onStatus event by the local connection object. The me
argument tells the script that the event was generated on the same script object that contains the
myOnStatus handler. The aInfoObject argument contains a Flash array object containing
information about the status of the message sending operation. The handler checks to see if the
aInfoObject argument contains an error. In this example, if there is an error, an error message is
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
infoObject, see the Flash
Communication Server MX documentation.
The
allowDomain event is generated each time the local connection object receives an incoming
message. This provides an opportunity for the
myAllowDomain callback handler to determine
whether the message is coming from a trusted domain. The
myAllowDomain callback handler
must return
TRUE in order for the incoming message to be processed.
The
myAllowDomain handler might look like this:
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 callback has returned TRUE, the local connection object forwards the
incoming message to the callback handler set up for the event. In this example, the subject of the
message is
incomingMessage and the callback handler is myIncomingMessage.
The
myIncomingMessage handler might look like the following:
on myIncomingMessage (me, aObject, aMessage)
member("chat output").text = & RETURN & aMessage
end myIncomingMessage
This handler simply appends the incoming message aMessage to the end of a chat output field.