In my flash project I have 3 layers. back layer contain Flvplayback video middle layer contain webcam stream front layer contain flvplayback video(with Transparent background).
webcam stream video is also transparent.
I add the stream from following code.
webCam=Camera.getCamera();
webCam.setMode(appWidth/scale,appHeight/scale,60);
video=new Video(appWidth/scale,appHeight/scale);
video.smoothing=true;
video.attachCamera(webCam);
bmpdata=new BitmapData(appWidth/scale,appHeight/scale);
bmpdata_bg=new BitmapData(appWidth/scale,appHeight/scale);
bmp=new Bitmap(bmpdata);
bmp.smoothing=true;
bmp.x = 256;
bmp.y = 374;
addChild(bmp);
and I update that webcam stream using following function
function onFrameEnter(evt:Event):void {
bmpdata.draw(video);
}
I want to know how to add this webcam stream to a middle layer and play it. Is there any way to add this webcam stream to flvplayback in the middle layer?
As far as I know it's impossible to refer to Flash IDE layers from Actionscript. There are a couple of workarounds you can do, though.
One is to have an empty instance movieclip in the desired layer with an instance name mcStream
. Then, you can use mcStream.addChild(bmp);
.
Another way is to refer to the item you want it to be under (we'll call it mcOverlay) and add it at its index. addChildAt(bmp, getChildIndex(mcOverlay))
This will push add it where the overlay is and push the overlay on top of it.
I definitely recommend having a look at http://www.adobe.com/devnet/flash/quickstart/display_list_programming_as3.html