Leon Gaban
Leon Gaban

Reputation: 39044

Why am I getting this error? Error #1006: draw is not a function

I have 2 classes with a draw function in them, my Background class and VideoDisplay class. I'm not done with the VideoDisplay class, but I put simple traces in it to test. I call both the Background and VideoDisplay the same way in my document class, but when I try to call the draw function of the VideoDisplay class I get this error:

Error #1006: draw is not a function.

My Document class code:

        //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);
    }

Basically the code above is the same! So I dunno why on the vd.draw line I'm getting that #1006 error

The code for the draw function in my VideoDisplay class:

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();
    }

The full output window trace/error message:

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()

Upvotes: 0

Views: 671

Answers (2)

sberry
sberry

Reputation: 132138

Perhaps a conflict with the Flex VideoDisplay class... http://livedocs.adobe.com/flex/3/html/help.html?content=controls_17.html

Just a guess.

Upvotes: 1

iandisme
iandisme

Reputation: 6406

If you're using Flex (or maybe even if you're not), your VideoDisplay class might be ambiguous with this one. Try renaming it or aliasing your import statements.

Upvotes: 1

Related Questions