2007-06-11

The rules of frame actions converting to a class definition ?

承上一篇: Frame Action 的 Function literal 裡的 Scope
個人「純猜測」可能轉換成類別定義:
package {
import flash.display.MovieClip;

public class TestMC8 extends MovieClip {
public var me:Object = this;
public var o:Object = {};
public var i:Number = 6;

public function TestMC8() {
addFrameScript(0, frame1);
}

internal function frame1():void {
o.a = function():void{
this.c = function():void{
};
};
o.b = function():void{
trace(i);
trace(this.i);
trace(me.i);
};
o.a();
o.b();
}
}
}

然而 frame1 應該不是 class member, 所以應該比較像這樣:
package {
import flash.display.MovieClip;

public class TestMC8a extends MovieClip {
public var me:Object = this;
public var o:Object = {};
public var i:Number = 6;

public function TestMC8a() {
function frame1():void{
o.a = function():void{
this.c = function():void{
};
};
o.b = function():void{
trace(i);
trace(this.i);
trace(me.i);
};
o.a();
o.b();
trace(this);
}

addFrameScript(0, function(){
frame1.apply(me);
}
);
}
}
}

紅色字的部份應該是在 addFrameScript() 裡面運作

沒有留言:

FB 留言