为什么我收到此错误?错误#1006:draw不是函数

时间:2010-01-08 20:26:13

标签: flash actionscript-3 class function

我有两个带有绘图功能的类,我的Background类和VideoDisplay类。我没有使用VideoDisplay类,但我在其中放入了简单的痕迹进行测试。我在文档类中以相同的方式调用Background和VideoDisplay,但是当我尝试调用VideoDisplay类的draw函数时,我收到此错误:

错误#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()

2 个答案:

答案 0 :(得分:1)

如果你正在使用Flex(或者即使你不是),你的VideoDisplay类可能与this one不明确。尝试重命名它或别名导入语句。

答案 1 :(得分:1)

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

只是一个猜测。