0

我已經看過像thisthisthisthis這樣的問題,但這些似乎都沒有描述我的問題?1120:未定義屬性[實例化變量]的訪問? (Flex)

我聲明這些變量:

<fx:Script> 
    <![CDATA[ 
     import assets.Page; 
     public var oneTwo:Page = new Page("..."); 
     public var oneThree:Page = new Page("..."); 
     protected var oneFour:Page = new Page("..."); 
     protected var oneFive:Page = new Page("..."); 
     protected var oneSix:Page = new Page("..."); 

...參照了確實存在的物體,和Flex是好的,與這些項目的建設者。接下來,我嘗試設置這些對象的其他屬性:

 oneThree.next = oneFour; 
     oneThree.prev = oneTwo; 
     oneFour.next = oneFive; 
     oneFour.prev = oneThree; 
     oneFive.next = oneSix; 
     oneFive.prev = oneFour; 

等。現在,當我點擊每一項,則Flex突出了每個實例變量,並確認所有的人都爲有效編碼中。但彙編給出:

-1120: Access of undefined property oneThree. 
-1120: Access of undefined property oneFour. 
-1120: Access of undefined property oneFour. 
-1120: Access of undefined property oneFive. 

等等,每次使用每個變量(在這裏的情況下這樣十二次)。你可以看到我做了一些公開的和一些保護,這似乎沒有什麼區別。

回答

0

[此問題] [1]問題使我找到了解決方案。

在第二個代碼塊的變量都需要自己的職能範圍內編輯,越來越:

<fx:Script> 
    <![CDATA[ 
     import assets.Page; 
     public var oneTwo:Page = new Page("..."); 
     public var oneThree:Page = new Page("..."); 
     protected var oneFour:Page = new Page("..."); 
     protected var oneFive:Page = new Page("..."); 
     protected var oneSix:Page = new Page("..."); 

     oneThree.next = oneFour; 
     oneThree.prev = oneTwo; 
     oneFour.next = oneFive; 
     oneFour.prev = oneThree; 
     oneFive.next = oneSix; 
     oneFive.prev = oneFour; 
    ]]> 
</fx:Script> 

,而不是這樣的:

<fx:Script> 
    <![CDATA[ 
     import assets.Page; 
     public var oneTwo:Page = new Page("..."); 
     public var oneThree:Page = new Page("..."); 
     protected var oneFour:Page = new Page("..."); 
     protected var oneFive:Page = new Page("..."); 
     protected var oneSix:Page = new Page("..."); 

     protected function _init():void 
     { 
      oneThree.next = oneFour; 
      oneThree.prev = oneTwo; 
      oneFour.next = oneFive; 
      oneFour.prev = oneThree; 
      oneFive.next = oneSix; 
      oneFive.prev = oneFour; 
     } 
    ]]> 
</fx:Script> 

是照顧錯誤的我。希望這可以幫助別人!

相關問題