●Creating a basic application (1)
http://livedocs.macromedia.com/labs/as3preview/docs/00000018.html
[Flash Programming ActionScript 3.0] > [Overview of ActionScript Programming] > [Getting Started with ActionScript] > [Creating a basic application]
// ActionScript 3.0クラス定義ファイル: Greeter.as
package {
public class Greeter {
public static function sayHello():String {
var greeting:String = "Hello World!";
return greeting;
}
}
}
●Creating a basic application (2)
http://livedocs.macromedia.com/labs/as3preview/docs/00000018.html
[Flash Programming ActionScript 3.0] > [Overview of ActionScript Programming] > [Getting Started with ActionScript] > [Creating a basic application]
// ActionScript 3.0クラス定義ファイル: Greeter.as
package {
public class Greeter {
public static var validNames:Array = ["Sammy", "Frank", "Dean"];
public static function sayHello(userName:String = ""):String {
var greeting:String;
if (userName == "") {
greeting = "Hello. Please type your user name, and then press the Enter key.";
} else if (validName(userName)) {
greeting = "Hello, " + userName + ".";
} else {
greeting = "Sorry, " + userName + ", you are not on the list.";
}
return greeting;
}
public static function validName(inputName:String = ""):Boolean {
if (validNames.indexOf(inputName) > -1) {
return true;
} else {
return false;
}
}
}
}