MACROMEDIA FLASH 8-FLASH Tutorials Manual page 260

Hide thumbs Also See for FLASH 8-FLASH:
Table of Contents

Advertisement

260 ActionScript: Work with Objects and Classes
To create objects from this class, you could now use the following code:
The following ActionScript is an example only. Do not enter the script in
your lesson FLA file.
var cliplessPedal:Product=new Product(1, "Clipless Pedal",
11);
var monkeyBar:Product=new Product(2, "Monkey Bar", 10);
However, in ActionScript 2.0, variables that are part of a class structure
should not be accessed directly. Write methods within the class that will
access these variables directly. Different methods should get and set
properties (known as "getter" and "setter" methods). You must indicate the
data type for both a method's return value and any parameters that are
passed to the method when it is called.
Specify the data type for method return
values
You must indicate data types for values returned by methods after the
method name and list of parameters, as in the following example:
The following ActionScript is an example only. Do not enter the script in
your lesson FLA file.
public function getProductName() :String
{
return name;
}
If no value is returned (for example, a property is being set), the data type is
:
Void
public function setProductName(productName:String) :Void
{
this.productName=productName;
}

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-FLASH and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF