【问题标题】:ActionScript 3 - accessing variable on root not workingActionScript 3 - 在根目录下访问变量不起作用
【发布时间】:2014-02-27 14:38:36
【问题描述】:

我有一个名为“测试”的变量(字符串)帧 1 场景 1。我还有一个名为“pointerMC”的影片剪辑。在pointerMC 中,我有另一个名为handMC 的影片剪辑。在 handMC 内部,我想像这样调度一个事件:

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.

为什么会出现这个错误?

【问题讨论】:

    标签: actionscript-3 flash root event-listener dispatchevent


    【解决方案1】:

    找到答案:

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

    工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多