views:

189

answers:

3

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()
+1  A: 

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.

iandisme
I'm using Flash, but will try renaming my class now :)
Leon
Ah, hey guys I found out that one of my MovieClips had a class name of VideoDisplay! I changed it, now I'm getting a new error: 1024: Overriding a function that is not marked for override.
Leon
Is the new error on the same line? If so, go for renaming the function.
iandisme
Yup, renaming fixed it :) I still don't know why it needed to be renamed, but oh well... works now :D
Leon
+1  A: 

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

Just a guess.

sberry2A
A: 

I had a MovieClip containing a Video object with the class name VideoDisplay, that was conflicting with my Class VideoDisplay.

So I renamed that movieClip to VidDisplay, which then produced this new error message:

1024: Overriding a function that is not marked for override.

Now, I have no idea what that means... so I just renamed my draw function inside VideoDisplay to drawVideo and now everything works. I'm assuming this has something to do with having 2 draw functions getting called in 2 classes, so I just renamed 1 of them.

Updated working code:

Document class

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

        vd = new VideoDisplay();
        vd.drawVideo(globalWidth, globalHeight, videoName);
        stage.addChild(vd);
    }

VideoDisplay class

public function drawVideo(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();
    }
Leon