如何访问 Costum Class 中的 Stage Class 属性?
班级:
package {
import Main;
import flash.events.*;
import flash.display.Sprite;
import flash.display.Stage;
public class Run extends Sprite {
var obj:a1_spr;
public function Run() {
runAssets();
}
private function runAssets():void {
obj = new a1_spr()
addChild(obj);
obj.x = stage.stageWidth/2;
}
}
}
输出:
TypeError: Error #1009: Cannot access a property or method of a null object reference.