Where To Go from Here
There are a lot of additional things you can do to enhance your webcam. I personally love tinkering, so I couldn't let well enough alone. I wanted to be able put in place a mechanism that would allow me to load one single URL to deliver either the Flash MX version or the older PHP-based JPEG to .swf version, so even Flash 3 players could view it. I also wanted to control who could actually see the stream, based on a user's IP or on my needs. So, I implemented in PHP a wrapper that I could call to determine the proper method for returning the correct file type, either a JPEG for the Flash 6 player or a .swf via PHP conversion for Flash 5 and lower. I also added in the code to filter out certain IP addresses, hosts, or ranges. I will leave a few things for you to find out and come up with on your own, but below you will find the sample PHP script I use to filter out IPs and to do my redirects. This should give you some hints about how to proceed and modify your own version. It should be noted that Macromedia's ColdFusion is well-suited for this task, and all of these scripts could easily be adapted to work the ColdFusion.
<? /* This script: showimage.php This PHP Script Redirects the loadMovie query of the Flash based webcam to the proper datasource. In your Actionscript you would simply change your loadMovie line to one of the following: loadMovie("http://www.impossibilities.com/webcam/showimage.php?type=XXXX", "target"); Where XXXX would be either jpeg for Flash 6 or swf for Flash 3-5 and target Would be your intended level or movieClip in Flash where you want the image loaded. */ /* If the URL encoded variable type contains the value jpeg then we know I want the Flash 6 version since I can handle JPEGS directly. Redirect me to the correct wrapper file. */ if ($type=="jpeg") { header("Location: http://www.impossibilities.com/webcam/loadjpeg.php"); exit; } /* If the URL encoded variable type contains the value swf then we know I want the PHP script to conver the JPEG to SWF on the server side and return the .swf file to my Flash 3-5 document. */ if ($type=="swf") { // This URL would be a variation of Stefans Flashwriter Toolkit for // converting a JPEG to SWF dynamically. header("Location: http://www.impossibilities.com/webcam/jpegtoswf.php"); exit; } ?> <? // This script: loadjpeg.php header("Content-type: image/jpeg"); // I want to filter out and provide a different image to all // viewers coming from the local internal LAN for this example. // This could be a series of evaluations of the PHP http environment variables // for IP addresses, HOST names, etc. $sub_net = (substr($REMOTE_ADDR, 0, 8)); // If its someone on the internal LAN return the predefined and uploaded "OFFLINE" JPEG // We use the PHP readfile command to pass thru the JPEG to the Flash player if ($sub_net == "192.168.0") { readfile("webcam32_off.jpg"); } else { // If its any other IP range, simply pass thru the regularly uploaded webcam image. readfile("webcam32.jpg"); } ?>
One other idea for you to pursue is to improve the system so that the image remains constant and there are no gaps in the display. You might be able to accomplish this by attaching MovieClips offstage, determining whether they are finished loading, and then changing their position. Another method you might consider is to simply have two target MovieClips on stage, and alternately load into them and simply swap their depths on the stage to provide a seamless view of the webcam feed without a visual interruption.