EasyManua.ls Logo

MACROMEDIA FLASH 8-FLASH - Page 261

MACROMEDIA FLASH 8-FLASH
292 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Create a custom class 261
Build a custom class
You’ll now build a new Product class with getter and setter methods and
create an object from the Product class.
1. Create an ActionScript file by doing one of the following:
If youre using Flash Professional 8, select File > New > ActionScript
File (Not Flash Document). Save the document with the name
Product.
If youre using Flash Basic 8, open a text editor, such as Notepad.
Save the file with the name Product.as. (Remember to give the file
the .as extension, to create an ActionScript file.)
2. Create a constructor for a Product class by creating a function called
Product that takes the arguments
id, prodName, and description:
function Product (id:Number, prodName:String,
description:String)
{}
3.
In the constructor function, set the properties of the Product class equal
to the setter methods that you will create:
setID(id);
setProdName(prodName);
setDescription(description);
4.
Surround the class keyword with the constructor function.
Declare each variable used in the class:
class Product
{
var id:Number;
var prodName:String;
var description:String
function Product (id:Number, prodName:String,
description:String)
{
setID(id);
setProdName(prodName);
setDescription(description);
}
}

Table of Contents

Related product manuals