?? 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 + -