22
Chapter 1: ActionScript Basics
Creating movie clips dynamically
Using ActionScript to create movie clips dynamically is
useful when you want to avoid manually creating movie clips on the Stage or attaching them from
the library. For example, you might create an image gallery with a large number of thumbnails
that you want to organize on the Stage. Using
MovieClip.createEmptyMovieClip()
lets you
create an application entirely using ActionScript.
To dynamically create a movie clip, use
MovieClip.createEmptyMovieClip()
, as shown in the
following example:
//Creates a movie clip to hold the container
this.createEmptyMovieClip("image_mc", 9);
//loads an image into image_mc
image_mc.loadMovie("picture.jpg");
The second example creates a movie clip called
square_mc
that uses the Drawing API to draw a
rectangle. Event handlers and the
startDrag()
and
stopDrag()
methods of the MovieClip class
are added to make the rectangle draggable.
this.createEmptyMovieClip("square_mc", 1);
square_mc.lineStyle(1, 0x000000, 100);
square_mc.beginFill(0xFF0000, 100);
square_mc.moveTo(100, 100);
square_mc.lineTo(200, 100);
square_mc.lineTo(200, 200);
square_mc.lineTo(100, 200);
square_mc.lineTo(100, 100);
square_mc.endFill();
square_mc.onPress = function() {
this.startDrag();
};
square_mc.onRelease = function() {
this.stopDrag();
};
The MovieClip class is the base class for Flex components. Although Macromedia supports some
of the MovieClip interface for use in Flex applications, much of the interface has been overridden
by Flex. For more information on using the MovieClip class with Flex, see
Developing Flex
Applications
.
Null data type
The null data type has only one value,
null
. This value means
no value
—that is, a lack of data.
You can assign the
null
value in a variety of situations to indicate that a property or variable does
not yet have a value assigned to it. The following list shows some examples:
•
To indicate that a variable exists but has not yet received a value
•
To indicate that a variable exists but no longer contains a value
•
As the return value of a function, to indicate that no value was available to be returned by
the function
•
As a parameter to a function, to indicate that a parameter is being omitted
Содержание FLEX
Страница 1: ...Flex ActionScript Language Reference ...
Страница 8: ......
Страница 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0 ...
Страница 76: ......
Страница 133: ...break 133 See also for for in do while while switch case continue throw try catch finally ...
Страница 135: ...case 135 See also break default strict equality switch ...
Страница 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while ...
Страница 229: ...while 229 i 3 The following result is written to the log file 0 3 6 9 12 15 18 See also do while continue for for in ...
Страница 808: ...808 Chapter 7 ActionScript for Flash ...
Страница 810: ...810 Appendix A Deprecated Flash 4 operators ...
Страница 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code ...
Страница 816: ...816 Appendix B Keyboard Keys and Key Code Values ...
Страница 822: ...822 Index ...