About data types
77
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();
};
For more information, see
Chapter 11, “Working with Movie Clips,” on page 351
and the
MovieClip entry in the
ActionScript 2.0 Language Reference
.
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. For example, you can assign the
null
value in
the following situations:
■
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
Several methods and functions return
null
if no value has been set. The following example
demonstrates how you can use
null
to test if form fields currently have form focus:
if (Selection.getFocus() == null) {
trace("no selection");
}
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...