空引用,AS3

时间:2015-11-20 20:59:39

标签: actionscript-3 flash

我正在为我的第一个Flash游戏创建一个基于文本的冒险游戏,目前我已经:

打字效果

按顺序显示零件

按键以继续/完成输入文字

等等。

现在,我正在努力做到这一点,所以选择出现在正确的部分。我已经完成了这个,但现在我需要显示运行该选项的可点击文本按钮(我正在使用flashdevelop)。我从this线程获得了一些代码(第二个答案)

尝试创建选择列表:

    for (var i:int = 0; i < optionsArray[currentChoicePart].length; i++) 
    {
        var textButton:Sprite = getTextButton(optionsArray[currentChoicePart][i])
        textButton.x = myTextField.x
        textButton.y = stage.stageHeight / 2 +50 - (i * 25)
        choicesOnScreen[textButton.name] = textButton // erroring line
        addChild(textButton)
    }

当它运行时,带有注释“错误行”的行表示textButton是一个空值。 (choicesOnScreen是一本字典)

0 个答案:

没有答案