Question

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.

Was it helpful?

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

OTHER TIPS

Remove the FLVPlayback object from stage and get rid of it completly so it doesnt block the name video anymore.

Then change your code like this:

import flash.media.video; //here you get the right video class from flash library



var video = new Video(); // this will work after the import is done
cam = Camera.getCamera();

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

   video.attachCamera(cam); 

    addChild(video) // brings video object to stage so its visible
}

You took the wrong component, but you want to create an Video instance first and then attach the cam to it... mostly right what you did

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top