1
我得到了錯誤1119,我不明白爲什麼。它讓我瘋狂 !不明白的錯誤1119
我有一個名爲 「useBox」 影片剪輯被稱爲在我Engine.as
package com.laserdragonuniversity.alpaca {
public class Engine extends MovieClip{
public static var toolbar:Toolbar;
public static var useBox:UseBox;
public function Engine(){
private function configLoaded(e:Event):void{
useBox = new UseBox(stage, usableItems[0]);
private function examine(e:MouseEvent):void{
stage.dispatchEvent(new Event("itemClicked"));
useBox = new UseBox(stage, e.currentTarget);
useBox.x = mouseX;
useBox.y = mouseY;
stage.addChild(useBox);
}
我有一個UseBox類:
UseBox.as:
package com.laserdragonuniversity.alpaca {
public class UseBox extends MovieClip{
public function UseBox(stageRef:Stage, thisThing:Object){
this.stageRef = stageRef;
this.thisThing = thisThing;
toolbar = Engine.toolbar;
batiments = Engine.batiments;
this.visible = true;
useButton.visible = false;
useButton2.visible = false;
}
而在Puzzle.as類中,我試圖使useButton可見。
package com.laserdragonuniversity.alpaca {
public class Puzzle extends MovieClip{
private var toolbar:Toolbar;
private var useBox:UseBox;
public function Puzzle(stageRef:Stage){
useBox = Engine.UseBox;
public function clickEmplacement2(event:MouseEvent):void {
useBox.useButton2.visible = true;
}
但我得到了錯誤1119:訪問可能未定義的屬性UseBox通過靜態類型的引用類。 (對於「useBox = Engine.UseBox」行)
你知道爲什麼嗎?
非常感謝您
爲什麼'Engine'的屬性靜態的?他們不應該。 – poke
您的益智類不知道Engine.UseBox是否已被初始化。由於Engine配置是異步加載的,Puzzle實例很可能在Engine的configLoaded函數之前加載。 – axelduch