Chapter 11
304
Using Flash objects in Lingo
With Director MX, you can create Flash ActionScript objects and access all of their properties
and methods. You can create a wide variety of Flash objects, including arrays, dates, Booleans,
XML objects, and net connection objects for use with Flash Communication Server MX. If you
have authored a Flash movie that contains ActionScript classes that generate custom objects, you
can access those objects in Lingo as well. You can also create references to existing ActionScript
objects with the
getVariable()
command. For more information on accessing these objects, see
“Using Lingo to set and test Flash variables” on page 301.
When creating Flash objects, you can choose to create an object within a Flash sprite, or you can
create a global Flash object.
•
To create a Flash object within a Flash sprite, you must have a Flash movie in the cast and a
Flash sprite on the Stage. Do not use a Flash cast member created with the Lingo command
new(#Flash)
, as this will only create a Flash cast member shell, which will contain no actual
internal Flash data. When you create a Flash object within a sprite, the object uses the
same instance of the Flash player that Director loads when the Flash cast member appears
on the Stage.
In your Lingo script, use the
newObject()
method with a sprite reference. If the object you
want to create requires parameters, include them with the
newObject()
command:
myNewFlashObject = sprite(1).newObject("Array", "apple", "orange", "banana")
In this example, the specified sprite,
sprite(1)
, is the Flash sprite. The object is an array.
(In Lingo, arrays are called lists.) The array contains three strings:
"apple"
,
"orange"
,
and
"banana"
.
•
To create a global Flash object, use the
newObject()
command without a sprite reference.
When you do this, Director loads a special instance of the Flash Player into memory. This way,
you can use Flash objects without the need for a Flash cast member or sprite.
In your Lingo, use the
newObject()
command without a sprite reference:
myNewFlashObject = newObject("Array", "apple", "orange", "banana")
Because Director loads an instance of the Flash Player when you first create a global Flash object
and each time you create a Flash sprite, you should avoid doing both in the same movie. This
causes an extra instance of the Flash Player to be loaded into memory, which can slow your
movie’s performance.
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.
The
newObject()
command 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()
command 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.
Содержание 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 ...