检测输入文本事件的输入文本字段不起作用,为什么显示错误 1119



我是编码新手,我正在学习一个教程,现在我在 actionscript 3.0 中出现错误,我试图制作一个文本字段来检测文本输入事件并将其显示在其中,

1119: Access of possibly undefined property text through a reference with static type Function.

脚本文件将影片剪辑与输入文本字段链接起来符号命名为 type

package
{
    import flash.display.MovieClip; 
    import flash.display.Sprite;
    import flash.display.SimpleButton;
    import flash.events.MouseEvent;
    import flash.events.TextEvent;
    import flash.text.TextField;
    public class text extends MovieClip
{
    function type()
{
    addEventListener(TextEvent.TEXT_INPUT, updateOutput);
}
    function updateOutput(event:TextEvent):void
    {
    var pressedKey:String = event.text;
    type.text = "You typed: " + pressedKey;
    }
}
}

问题是这一行:

type.text = "You typed: " + pressedKey;

该行中的"type"一词是指您创建的称为 type 的函数。您正在尝试在该函数上设置一个名为 text 的属性,但它没有该属性,因此您会收到错误。

类型应更改为对尝试更新的文本字段的引用。

最新更新