
194
Chapter 9: Using Flash, Flash Components, and Other Interactive Media Types
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
“Managing Xtra extensions for distributed movies”
on page 450
.
The
newObject()
method creates the object you specify and a reference to it. In the preceding
examples, the object is an array and the reference is stored in the variable named
myNewFlashObject
. The first parameter included with the
newObject()
method is the type of
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
setCallback()
method.
•
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
netConnection
object is created along with a reference to
it named
myConnection
. The second line calls the handler named
dirOnStatusHandler
whenever the
myConnection
object generates an
onStatus
event. The argument
me
indicates that
the handler is located in the same script object that the
setCallback()
method is being issued
in. In this case, that script object is attached to sprite 1.
Содержание DIRECTOR MX 2004-USING DIRECTOR
Страница 1: ...DIRECTOR MX 2004 Using Director...
Страница 16: ...16 Chapter 1 Introduction...
Страница 82: ...82 Chapter 3 Sprites...
Страница 98: ...98 Chapter 4 Animation...
Страница 134: ...134 Chapter 5 Bitmaps...
Страница 242: ...242 Chapter 10 Sound and Synchronization...
Страница 274: ...274 Chapter 11 Using Digital Video...
Страница 290: ...290 Chapter 12 Behaviors...
Страница 302: ...302 Chapter 13 Navigation and User Interaction...
Страница 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Страница 392: ...392 Chapter 16 Working with Models and Model Resources...
Страница 418: ...418 Chapter 18 Movies in a Window...
Страница 446: ...446 Chapter 22 Managing and Testing Director Projects...