Using (web) cam from loaded swf file in AIR application
Hi everyone,
I am currently working on a project where a host application (AIR 3.4) loads different client applications which were created as individual .swf files to enable different interactivity without touching the host.
For example there is a video player application as client and a client which loads RSS feeds from the net and so on. Now I want to create a client that can capture footage from an installed webcam.
I've written a short test and loaded it into my host application and there I get no feed from the camera. When I test the client on it's own I have no problem with displaying the video feed in the holder movieclip. Is there an issue I've been missing?
The code to the client is something like that:
private function fnc_addedToStage(evt: Event): void{
fnc_dispatchErrorMessage(this.name + ": Has beend added to stage");
// clean up the EventListener
this.removeEventListener(Event.ADDED_TO_STAGE, fnc_addedToStage);
// setup the video window
var video = new Video();
video.smoothing = false;
video.width = outputWindow.width;
video.height = outputWindow.height;
// add it to the outputWindow holder sprite
outputWindow.addChild(video);
// setup the camera
var camera = Camera.getCamera();
// width, height, fps && maximum quality
camera.setMode(320, 240, 30);
camera.setQuality(0, 100);
camera.addEventListener(StatusEvent.STATUS, statusHandler);
fnc_dispatchErrorMessage("Camera: " + Camera.isSupported);
// attach the camera
video.attachCamera(camera);
}
fnc_dispatchErrorMessage is a wrapper function to send my trace statements to a log file in the host application. outputWindow is a movie clip on the stage which functions as a content holder.
The loading component of the host looks like that:
private function fnc_pageLoaded(evt: Event): void{
// clean up the eventListener
pageSWFLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, fnc_pageLoaded);
// casting it into the container movieClip, so that it's functions can be accessed
//pageContainer = new MovieClip();
pageContainer = MovieClip(pageSWFLoader.contentLoaderInfo.content);
// setting up the dimensions and position loaded from the xml file
pageContainer.width = Number(pageConfig.fnc_getSingleElement("pageWidth"));
pageContainer.height = Number(pageConfig.fnc_getSingleElement("pageHeight"));
pageContainer.x = Number(pageConfig.fnc_getSingleElement("pagePositionX"));
pageContainer.y = Number(pageConfig.fnc_getSingleElement("pagePositionY"));
pageContainer.addEventListener("calledError", fnc_pageContainerError);
// add it to the display list
addChild(pageContainer);
// and so on...
fnc_getSingleElement reads a value from a configuration xml file.
Any help would be great, cause I'm totally stuck at the moment. And searching in the AS3 API and Google didn't get me any results.
Thank you.
