![MACROMEDIA FLASH MX 2004-LEARNING FLASH Скачать руководство пользователя страница 119](http://html1.mh-extra.com/html/macromedia/flash-mx-2004-learning-flash/flash-mx-2004-learning-flash_manual_3379009119.webp)
About extending existing classes
119
3.
Verify that you created the objects as follows:
var handleBars:Product = new Product (1, "ATB", "Available in comfort and
aero design");
var pedals:Product=new Product(0,"Clipless Pedals","Excellent cleat
engagement");
4.
Trace the description property of pedals:
trace (pedals.getDescription ());
5.
Save and test the document. You should see the description of pedals in the Output panel.
Note:
An example finished file of the document you just created, named handson2.fla, is located in
your finished files folder. For the path, see
“Set up your workspace” on page 113
.
About extending existing classes
The
extends
keyword in ActionScript 2.0 allows you to use all the methods and properties of an
existing class in a new class. For example, if you wanted to define a class that inherited everything
from the MovieClip class, you could use the following:
class Drag extends MovieClip
{}
The Drag class now inherits all properties and methods from the existing MovieClip class, and
you can use MovieClip properties and methods anywhere within the class definition, as in the
following example:
Note:
The following ActionScript is an example only. You should not enter the script in your lesson
FLA file.
class Drag extends MovieClip
{
// constructor
function Drag ()
{
onPress=doDrag;
onRelease=doDrop;
}
private function doDrag():Void
{
this.startDrag();
}
private function doDrop():Void
{
this.stopDrag();
}
}
Note:
The Convert to Symbol dialog box now offers a class field in which you can associate visual
objects (such as movie clip) with any class that you define in ActionScript 2.0.
Содержание FLASH MX 2004-LEARNING FLASH
Страница 1: ...Learning Flash...
Страница 8: ...8 Contents...
Страница 34: ...34 Chapter 3 Write Scripts with ActionScript...
Страница 54: ...54 Chapter 6 Create a User Interface with Layout Tools...
Страница 62: ...62 Chapter 7 Draw in Flash...
Страница 68: ...68 Chapter 8 Create Symbols and Instances...
Страница 76: ...76 Chapter 9 Add Animation and Navigation to Buttons...
Страница 104: ...104 Chapter 13 Add Interactivity with ActionScript...
Страница 112: ...112 Chapter 14 Create a Form with Conditional Logic and Send Data...
Страница 122: ...122 Chapter 15 Work with Objects and Classes Using ActionScript 2 0...