198
Chapter 9: Using Flash, Flash Components, and Other Interactive Media Types
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()
method and all the
setCallback()
methods, you must add a
connect()
method. This is actually a Flash
ActionScript method 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 2004
Macromedia Flash Communication Server MX allows Flash content 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 script that you use to
communicate with the server.
As with any Flash ActionScript object you create by using script, you use the exact same methods
and properties to manipulate the object as you would in ActionScript. For a detailed example, see
the previous section. The Macromedia Director MX 2004 installation CD for Windows includes
Flash Communication Server MX Personal Edition, the Flash Communication Server MX
authoring components for Flash, and documentation. The Macromedia Director MX 2004
installation CD for Macintosh includes the Flash Communication Server MX authoring
components for Flash and documentation.
The steps required to communicate with Flash Communication Server MX are identical to those
you would use in ActionScript.
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...