Search code examples
actionscript-3flashactionscriptflash-cs4

How do I create Video object statically on stage?


Needless to say I am a beginner in Flash. I want to add Video Object to my stage. How do I do that? In my components window the closes component I see is FLVPlayback. I want to show my webcam. Well my stage has an instance of FLVPlayback and I named it video.

I then try to show webcam using:

cam = Camera.getCamera();
            if(cam != null)
            {
                cam.setQuality(144000, 85);
                cam.setMode(320, 240, 15);
                cam.setKeyFrameInterval(60);

                video.attachCamera(cam);


            }

in a button click but I get this error:

1061: Call to a possibly undefined method attachCamera through a reference with static type fl.video:FLVPlayback.

Note: All the examples on the web dynamically create Video. It works that way but how I want to create my video object on stage only and position it properly. I don't want to create it at runtime using new.


Solution

  • Based on your error message, "video" is an instance of FLVPlayback, which, according to the documentation, wraps a VideoPlayer object. It looks like FLVPlayback provides most of the same methods as VideoPlayer, which is why you got the two confused, but one method FLVPlayback does not provide is attachCamera().

    Try this instead:

    video.getVideoPlayer(video.activeVideoPlayerIndex).attachCamera(cam);