【问题标题】:How to change null values?如何更改空值?
【发布时间】:2013-07-22 04:46:37
【问题描述】:

代码有效但返回 以下错误 -

TypeError: 错误 #1009: 无法访问 null 的属性或方法 object reference.at lost_fla ::MainTimeline / check() [lost_fla.MainTimeline :: frame1: 44]

trace (smb_btn) = null

跟踪(检查)=函数(){}

trace (txt_inpt) = null

可以做些什么来改变空值?

import fl.controls.Button
import fl.controls.TextInput
import flash.utils.Timer
import flash.events.MouseEvent

        smb_btn.addEventListener (MouseEvent.CLICK, check);
    function check (e:MouseEvent):void{
        if (txt_inpt.text == "12345"){
            hotel++
            gotoAndPlay (952, "Cena 2");
            trace(smb_btn)
            trace(txt_inpt)
            }
            if (txt_inpt.text == "131313"){
            gotoAndPlay (735, "Cena 3");
            }
            if (txt_inpt.text == "t"){
            gotoAndPlay (693, "Cena 3");
            }
            if (txt_inpt.text == "141414"){
            gotoAndPlay (727, "Cena 4");
            }
        if (txt_inpt.text == "maze"){
            SoundMixer.stopAll();
            gotoAndPlay (483,"Cena 7");
            }   
        if (txt_inpt.text == "54321"){
            gotoAndPlay (239,"Cena 4");
            }
        if (txt_inpt.text == "12123"){
            gotoAndPlay (358,"Cena 3");
            }
        if (txt_inpt.text == "191918"){
            stone++
            stone++
            stone++
            SoundMixer.stopAll();
            gotoAndPlay (950,"Cena 8");
            }
        }

【问题讨论】:

  • dropbox.com/s/jnn9sofj42tqey2/lost.fla

标签: actionscript-3 flash function null


【解决方案1】:

您应该验证您的文本字段和按钮的名称,它们的名称应该与代码中的拼写完全一样,并且应该在设计它们所在的 MC 时指定名称。

【讨论】:

  • 检查!他们是!为了证明我复制和粘贴。还是一样的错误。
  • 好的,检查代码上下文。这些 TF 和按钮可能位于容器 MC 中,这意味着您必须通过该 MC 来处理它们,例如container_mc.smb_btn。此外,一般来说,空错误就是这样,有些东西不存在,必须将它放在你需要的地方。
  • 您在表单中管理的“状态”以及这些组件的可见性取决于状态
  • @JoeTaras 不应该依赖,可见性不会使变量无效。很可能他搞砸了控制和框架。
  • @Vesper。嗨,状态可见性对图形对象的影响。你有 txt_inp。如果此组件通过 includeIn 语句链接到状态,则在状态更改之前为 NULL。代码,因为我是红色的,没关系,它需要与用户交互才能最终理解一个问题。
【解决方案2】:

Apple 收到错误的软件并批准。由于该错误甚至不会引起问题,因此我认为没有被认真对待,但它仍然存在,我只是忽略了它的存在。我感谢大家的帮助。 Vesper的特殊坦克。

【讨论】:

    猜你喜欢
    • 2021-01-10
    • 2013-10-29
    • 1970-01-01
    • 2017-01-29
    • 2020-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多