Using Flash and Other Interactive Media Types
309
Sending messages and closing the connection
In order to complete your script, you must finish the
beginSprite
handler and write handlers for
sending messages from the object and closing the connection when you are finished using it.
•
To finish the
beginSprite
handler that already contains the
newObject()
command and all
the
setCallback()
commands, you must add a
connect()
command. This is actually a Flash
ActionScript command that you send to the local connection object you created.
pLocalConn.connect(pCon_name)
The argument
pCon_name
gives the actual connection a name, “userA”, that was declared at the
beginning of the script.
•
To send messages, write a handler that uses the
send()
method of the local connection object:
on sendMessage (me, aMessage)
tMessage = pCon_name && ":" && aMessage
pLocalConn.send(pOtherCon_name, "incomingMessage", tMessage)
end sendMessage
The
send()
method requires three arguments: the recipient of the message, the event to be
triggered when the message is received, and the message itself.
•
To close the connection, write a handler that uses the
close()
method of the local
connection object:
on closeConnection (me)
pLocalConn.close()
end closeConnection
You can call this handler from any other handler by using the statement:
sendSprite (1, #closeConnection)
You might also use the
close()
method in an
endSprite
handler:
on endSprite (me)
pLocalConn.close()
end endSprite
Now that the local connection object is set up and it has handlers for callbacks, sending messages,
and closing the connection, it is ready to be used by the movie.
Using Flash Communication Server MX
Macromedia Flash Communication Server MX allows Flash movies on separate computers to
share information, including sound, video, text and other data in real time. You can use Flash
Communication Server MX in Director by using Flash cast members that are designed to work
with the server, or by creating
NetConnection
and
NetStream
objects in Lingo that you use to
communicate with the server.
As with any Flash ActionScript object you create in Lingo, you use the exact same commands and
properties to manipulate the object as you would in ActionScript. For a detailed example, see the
previous section. The Director MX installation CD for Windows includes Flash Communication
Server MX Personal Edition, the Flash Communication Server MX authoring components for
Flash MX, and documentation. The Director MX installation CD for Macintosh includes the
Flash Communication Server MX authoring components for Flash MX and documentation. For
specific information about the
NetConnection
and
NetStream
objects and how to connect to the
FlashCom server, refer to the Flash Communication Server MX documentation.
Содержание 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...