2014-02-27 40 views
0

我有一個變量(字符串)框架1場景1叫'測試'。我也有一個叫做'pointerMC'的movieclip。在pointerMC裏面,我有另一個叫做handMC的movieclip。裏面handMC,我要派遣一個事件,像這樣:ActionScript 3 - 訪問變量對根目錄不起作用

root.dispatchEvent(new Event("eventName")); 

除了我想「eventName的」是「測試」變量持有一個字符串,所以是這樣的:

root.dispatchEvent(new Event(root.test)); 

但當我這樣做,它會給出錯誤說:

Symbol 'handMC', Layer 'actions', Frame 20, Line 2 1119: Access of possibly undefined property test through a reference with static type flash.display:DisplayObject. 

爲什麼我得到這個錯誤?

回答

0

找到了答案:

root.dispatchEvent(new Event(MovieClip(root).test)); 

工作。