【问题标题】:Why am I getting this error? Error #1006: draw is not a function为什么我会收到此错误?错误 #1006:draw 不是函数
【发布时间】:2011-01-03 01:59:28
【问题描述】:

我有 2 个具有绘图功能的类,我的 Background 类和 VideoDisplay 类。我还没有完成 VideoDisplay 类,但我在其中放置了简单的跟踪以进行测试。我在文档类中以相同的方式调用 Background 和 VideoDisplay,但是当我尝试调用 VideoDisplay 类的绘图函数时,我收到此错误:

错误 #1006:draw 不是函数。

我的文档类代码:

        //this is inside of onBulkLoadComplete which is called from init
        drawBackground();
        drawVideo();
    }

    private function drawBackground():void
    {
        trace("\r"+"drawBackground(); ---------- called");

        bg = new Background();
        bg.draw(globalWidth, globalHeight, firstTitle);
        stage.addChild(bg);
    }

    private function drawVideo():void
    {
        trace("\r"+"drawVideo(); ---------- called");

        vd = new VideoDisplay();
        vd.draw(globalWidth, globalHeight, videoName); //<-- problem
        stage.addChild(vd);
    }

基本上上面的代码是一样的!所以我不知道为什么在 vd.draw 行我收到 #1006 错误

我的 VideoDisplay 类中绘制函数的代码:

public function draw(w, h, flvUrl):void
    {           
        sizeW = w;
        sizeH = h;
        flvSource = flvUrl;

        trace("VideoDisplay.sizeW     = "+sizeW);
        trace("VideoDisplay.sizeH     = "+sizeh);
        trace("VideoDisplay.flvSource = "+flvSource);

        backing.graphics.beginFill(bgColor);
        backing.graphics.lineStyle(borderSize, borderColor);
        backing.graphics.drawRoundRect(position, position, sizeW-9, sizeH-9, cornerRadius);
        backing.graphics.endFill();
    }

完整的输出窗口跟踪/错误消息:

drawBackground(); ---------- called
Background.sizeW = 520
Background.sizeH = 510
Background.mainTitle = Video Title

drawVideo(); ---------- called
TypeError: Error #1006: draw is not a function.
at com.leongaban.TEN::TEN/drawVideo()
at com.leongaban.TEN::TEN/onBulkLoadComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at br.com.stimuli.loading::BulkLoader/_onAllLoaded()
at br.com.stimuli.loading::BulkLoader/_onItemComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at br.com.stimuli.loading.loadingtypes::LoadingItem/onCompleteHandler()
at br.com.stimuli.loading.loadingtypes::XMLItem/onCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

【问题讨论】:

    标签: flash actionscript-3 class function


    【解决方案1】:

    如果您使用的是 Flex(或者即使您没有使用),您的 VideoDisplay 类可能与 this one 有歧义。尝试重命名它或为你的 import 语句起别名。

    【讨论】:

    • 我正在使用 Flash,但现在将尝试重命名我的课程 :)
    • 啊,嘿伙计们,我发现我的一个 MovieClip 的类名是 VideoDisplay!我更改了它,现在我收到一个新错误:1024:覆盖未标记为覆盖的函数。
    • 新错误是否在同一行?如果是这样,请重命名函数。
    • 是的,重命名修复了它 :) 我仍然不知道为什么它需要重命名,但是哦……现在可以工作了:D
    【解决方案2】:

    可能与 Flex VideoDisplay 类冲突... http://livedocs.adobe.com/flex/3/html/help.html?content=controls_17.html

    只是猜测。

    【讨论】:

      猜你喜欢
      • 2019-10-14
      • 2023-01-24
      • 2018-06-22
      • 2016-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-24
      相关资源
      最近更新 更多