Chapter 11
306
Using the Flash local connection object
Macromedia Flash MX includes an object type called local connection. The Flash local
connection object can be very useful for allowing separate movies on the same computer to
connect to and communicate with each other. Because the local connection object is a Flash
object supported in Director, it can allow communication between separate Flash movies,
Director movies, or combinations of the two. You can use the messaging capability of the local
connection object for simple tasks such as exchanging chat messages, or more complex ones such
as exchanging sprite property data.
To use the local connection object, you can either create a global local connection object or
associate the object with a Flash sprite in the Score. Once you have created the object, you can
control it entirely through Lingo. The following are examples of a script that is attached to a Flash
sprite in channel 1 of the Score. The script contains a
beginSprite
handler and other handlers
that manage the local connection object.
Initialize properties
The first thing to do is declare some properties that you will use throughout the local connection
script to store references to the local connection object and 2 connections, one outgoing and
one incoming.
•
The property
pCon_name
stores the name of an outgoing connection
•
The property
pOtherCon_name
stores the name of an incoming connection
•
The property
pLocalCon
stores a reference to the local connection object
The beginning of the script might look like this, including the start of the
beginSprite
handler:
property pCon_name
property pOtherCon_name
property pLocalCon
on beginSprite (me)
pCon_name = "userA"
pOtherCon_name = "userB"
Creating the local connection object
The next step is to create a new local connection object. Once the object is created, you can use
the
setCallback()
command to set up handlers to respond to the events the local connection
object generates. You can then also use the methods of the local connection object to connect to
other movies and send messages.
•
To create the new local connection object, use the
newObject()
command:
pLocalConn = sprite(1).newObject("LocalConnection")
This Lingo assigns the property
pLocalConn
to be a reference to the newly created object.
Содержание 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...