Actionscript 3 AS3:Flash抛出类型错误#1006值不是一个似乎没有理由的函数;这是虫子吗?

Actionscript 3 AS3:Flash抛出类型错误#1006值不是一个似乎没有理由的函数;这是虫子吗?,actionscript-3,flash,Actionscript 3,Flash,Flash似乎在欺骗我,并抛出了以下错误: TypeError: Error #1006: value is not a function. at sweg::Force/setTxt()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\sweg\Force.as:459] at Main/CheckOnStage()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\Main.as:248]

Flash似乎在欺骗我,并抛出了以下错误:

TypeError: Error #1006: value is not a function.
    at sweg::Force/setTxt()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\sweg\Force.as:459]
    at Main/CheckOnStage()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\Main.as:248]
    at sweg::Force/removed()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\sweg\Force.as:192]
    at flash.display::DisplayObjectContainer/removeChild()
    at Main/init()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\Main.as:310]
    at Main/Start()[C:\Users\lamide97\Google Drive\OneDrive\COMP4\Main.as:107]
似乎没有理由。我查看了其他几个
#1006 TypeError
问题,但它们没有我的问题。所以我决定自己来修。令人惊讶的是,这并不需要很长时间;解决方案是一条跟踪语句。但我很困惑,为什么仅仅追踪一个值就能解决这个问题

这里有一个前提:我有一个
Force
类,一旦添加到stage中,它将使用stage的magnity属性设置文本框中的文本。它指定的文本框的文本与力的名称相对应

代码如下:

public function setTxt():void
    {
        switch (this.name)
        {
            case "Force 1" :
                _magtText.text = "P";
                _forceFormat.color = 0x33CCFF
                //trace(_magt); If I uncomment this line then everything works
                (this.parent as MovieClip).force1.text = String(Math.round(_magt * 100) / 100);
                //line above is line 459
                break;

            case "Force 2" :
                _magtText.text = "Q";
                _forceFormat.color = 0xFF6600;
                (this.parent as MovieClip).force2.text = String(Math.round(_magt * 100) / 100);
                break;

            case "Force 3" :
                _magtText.text = "F";
                _forceFormat.color = 0x003300;
                (this.parent as MovieClip).force3.text = String(Math.round(_magt * 100) / 100);
                break;

            case "Force 4" :
                _magtText.text = "A";
                _forceFormat.color = 0xFF00FF;
                (this.parent as MovieClip).force4.text = String(Math.round(_magt * 100) / 100);
                break;

            case "Tension 1" :
            case "Tension" :
                _magtText.text = "T";
                _forceFormat.color = 0x003300;
                (this.parent as MovieClip).force3.text = String(Math.round(_magt * 100) / 100);
                break;

            case "Tension 2" :
                _magtText.text = "T`";
                _forceFormat.color = 0xFF00FF;
                (this.parent as MovieClip).force4.text = String(Math.round(_magt * 100) / 100);
                break;

            case "Resultant F" :
                _magtText.text = "R";
                _forceFormat.color = 0xFF0000;
                (this.parent as MovieClip).resBox.text = String(Math.round(_magt * 100) / 100);
                (this.parent as MovieClip).resAng.text = roundNum(_degrees.toFixed(3));
                break;

            default :
                _magtText.text = "X";
        }
        _magtText.setTextFormat(_forceFormat);
    }
我怀疑这与
\u magt
属性有关,因为在此之前,我在继承
Force
Weight
子类中遇到了类似的问题,在我添加了一些分号后,问题似乎自行解决了

if (_magt >= 0)
    {
        drawForce();
    }
    else
    {
        drawForce(0x33CCFF, 0xCCCCCC, 0.3);
    }

    (this.parent as MovieClip).weightBox.text = roundNum(_magt.toFixed(3))
    (this.parent as MovieClip).particle.mass = _magt;
    //Line above throws a "Call to a possibly undefined method _magt" error. Doesn't work without the semi-colon.
    (this.parent as MovieClip).massNum.text = roundNum(Number(_magt / 9.8).toFixed(3))
    (this.parent as MovieClip).weightSlider.value = _magt;
    //Line above throws the same error; also doesn't work without semi colon.
    (this.parent as MovieClip).massSlider.value = _magt / 9.8

    (this.parent as MovieClip).dragCalc(this);
我不知道为什么flash会认为
\u magt
属性(我声明为
Number
)是一种方法。不过,我确实有一个
get magt
函数,但据我所知,我不认为Flash会将函数和属性相互混淆,因为它们不共享名称空间

更奇怪的是,当我有一个名为“合力F”的力时,它的
\u magt
似乎没有问题,但所有其他力都有问题

我最初的猜测是,在某个地方,
\u magt
NaN
。但我知道这是不可能的,因为力是用147的
\u magt
实例化的,这是跟踪的震级所显示的,并且没有在其他任何地方分配新的值

我不知道这是否是一些低调的语法错误,因为我还是一个初学者,可能有一些非常明显的东西我没有看到

虽然从技术上讲我已经解决了这个问题,但我想知道是什么导致了这个问题,因为我有一种感觉,以后它可能会悄悄地爬到我身上


谢谢阅读。

Force中的行号“459”中的代码是什么。如“我不确定它是否能解决您的问题,但请尝试将颜色值用引号括起来,并在末尾加上分号。”line@MartonPallagi出于某种原因,这似乎奏效了。我认为这与分号有关。如果我将
\u forceFormat.color=0x33CCFF
更改为
\u forceFormat.color=0x33CCFF那么不管颜色是否在引号中,似乎都没有问题。为什么会发生这种情况?我想这只是自动插入分号不直观-我认为flash试图像函数一样执行它
0x33CCFF(this.parent as MovieClip)
。这对我来说是个奇怪的领域,所以我一直在插入那些分号:)