![MACROMEDIA FLASH 8-FLASH Tutorials Manual Download Page 259](http://html2.mh-extra.com/html/macromedia/flash-8-flash/flash-8-flash_tutorials-manual_3348958259.webp)
Create a custom class 259
Create a custom class
Although ActionScript includes many classes of objects, such as the
MovieClip class and the Color class, there will be times when you need to
construct your own classes so you can create objects based on a particular
set of properties or methods.
To create a class that defines each of the new objects, you create a
constructor for a custom object class and then create new object instances
based on that new class, as in the following example:
function Product (id:Number, prodName:String, price:Number)
{
this.id = id;
this.prodName = prodName;
this.price = price;
}
To properly define a class in ActionScript 2.0, you must surround all classes
by the
class
keyword, and you must declare all variables in the
constructor outside of the constructor.
class Product
{
// variable declarations
var id:Number
var prodName:String
var price:Number
// constructor
function Product (id:Number, prodName:String,
price:Number){
this.id = id;
this.prodName = prodName;
this.price = price;
}
}
NO
T
E
The following ActionScript is an example only. Do not enter the script in
your lesson FLA file.
NO
TE
The following ActionScript is an example only. Do not enter the script in
your lesson FLA file.
Summary of Contents for FLASH 8-FLASH
Page 1: ...Flash Tutorials...
Page 10: ...10 Contents...
Page 12: ...12 Introduction...
Page 42: ...42 Basic Tasks Creating a banner Part 1...
Page 78: ...78 Basic Tasks Creating a banner Part 3...
Page 88: ...88 Basic Tasks Create Accessible Flash Content...
Page 106: ...106 Basic Tasks Create an Application...
Page 116: ...116 Basic Tasks Use Layout Tools...
Page 124: ...124 Basic Tasks Create Symbols and Instances...
Page 134: ...134 Basic Tasks Add Button Animation and Navigation...
Page 144: ...144 Basic Tasks Create a Presentation with Screens Flash Professional Only...
Page 192: ...192 Creating Graphics Applying Gradients...
Page 198: ...198 Creating Graphics Apply Graphic Filters and Blends Flash Professional Only...
Page 224: ...224 ActionScript Use Script Assist mode...
Page 268: ...268 ActionScript Work with Objects and Classes...
Page 270: ...270 Data Integration Overview Flash Professional Only...