Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 28

Programming actionscript 3.0
Table of Contents

Advertisement

5.
In the New ActionScript File dialog box, select HelloWorld as the parent folder, type
Greeter.as the filename, and then click Finish.
A new ActionScript editing window is displayed.
Continue with
"Adding code to the Greeter class" on page
Adding code to the Greeter class
The Greeter class defines an object,
application.
To add code to the Greeter class:
1.
Type the following code into the new file:
package
{
public class Greeter
{
public function sayHello():String
{
var greeting:String;
greeting = "Hello World!";
return greeting;
}
}
}
The Greeter class includes a single
"Hello" to the user name that is given.
2.
Select File > Save to save this ActionScript file.
The Greeter class is now ready to be used in a Flash or Flex application.
Creating an application that uses your ActionScript
code
The Greeter class that you have built defines a self-contained set of software functions, but it
does not represent a complete application. To use the class, you need to create a Flash
document or Flex application.
The HelloWorld application creates an new instance of the Greeter class. Here's how to attach
the Greeter class to your application.
28
Getting Started with ActionScript
, that you will be able to use in your HelloWorld
Greeter
sayHello() method
28.
, which returns a string that says

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents