📄 sampleconstructor.as
字号:
package org.kingda.book.basicoop
{
import flash.display.Sprite;
public class SampleConstructor extends Sprite
{
public function SampleConstructor() {
var foo:Foo = new Foo();
trace (foo);
//输出:[object Foo]
var bar:Bar = new Bar("ActionScript 3");
/*输出:
Bar's constructor!
init executed!
*/
trace (bar);
//输出:[object Bar]
trace (bar.isOK);
trace (bar.hello);
//输出:true
}
}
}
class Foo {
public function Foo() {
trace ("Foo's constructor!!");
return;
trace ("We cannot see this trace");
}
}
class Bar {
public var isOK:Boolean;
public var hello:String;
public function Bar(hS:String) {
trace ("Bar's constructor!!");
isOK = true;
hello = hS; //将构造函数的参数赋值给实例属性hello
init();
return;
trace ("We cannot see this trace, cause it is after 'return'");
}
function init():void {
trace ("init executed!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -