The Flash asset commonPlayer feature gives you the ability to load multiple Flash sprites into one
instance of the Flash Player; this provides better Flash playback performance in Director objects
that have a great deal of Flash assets.
Note: If you do not import any Flash cast members, you must manually add the Flash Asset Xtra to
your movie's Xtra list for global Flash objects to work correctly in Shockwave and projectors. For
more information about the movie Xtra list, see
on page
450.
The
newObject()
examples, the object is an array and the reference is stored in the variable named
myNewFlashObject
object to create. The subsequent parameters are the values to put into the array. In this case, the
values are a list of names of fruit.
•
To access a property of the object, such as the array's length, you only need to refer to the
property as a property of the object reference you created:
put myNewFlashObject.length
-- 3
•
To access a part of the object, such as the value of the third item in the array, use the
following syntax:
put myNewFlashObject[2]
-- "banana"
Note: The items in an ActionScript array are numbered beginning with zero, while the items in a
script list are numbered beginning with one. Be sure to use the correct number when referring to
items in arrays or lists.
•
To access a method of the object, use the same syntax and specify the method name after the
object reference:
myNewFlashObject.sort()
For more information about the types of objects supported by Flash and the methods and
properties used to control them, see the Flash documentation.
Setting callbacks for Flash objects
Some kinds of Flash objects generate events that must be routed to an appropriate script handler.
For example, a Flash Communication Server connection object generates an event each time an
incoming message is received from the server. You can set script to route events like this to a
specific handler in a specific script object by using the
•
To set up a callback for an event from a Flash object, use script similar to this:
myConnection = sprite(1).newObject("NetConnection")
sprite(1).setCallback(myConnection, "onStatus", #dirOnStatusHandler, me)
In the first line of this example, a new
it named
myConnection
whenever the
myConnection
the handler is located in the same script object that the
in. In this case, that script object is attached to sprite 1.
194
Chapter 9: Using Flash, Flash Components, and Other Interactive Media Types
method creates the object you specify and a reference to it. In the preceding
. The first parameter included with the
netConnection
. The second line calls the handler named
object generates an
"Managing Xtra extensions for distributed movies"
newObject()
setCallback()
object is created along with a reference to
dirOnStatusHandler
event. The argument
onStatus
setCallback()
method is the type of
method.
indicates that
me
method is being issued
Need help?
Do you have a question about the DIRECTOR MX 2004-USING DIRECTOR and is the answer not in the manual?
Questions and answers