Sample Actionscript for showing 4 webcams on a single Chumby display and cycling through 9 webcams. Every second replacing one of the images with the next one in the sequence.
<br /> class CamView.Main {<br><br /> static var urls:Array = [<br><br /> "http://192.168.2.10/cam1.jpg",<br><br /> "http://192.168.2.10/cam2.jpg",<br><br /> "http://192.168.2.10/cam3.jpg",<br><br /> "http://192.168.2.10/cam4.jpg",<br><br /> "http://192.168.2.10/cam5.jpg",<br><br /> "http://192.168.2.10/cam6.jpg",<br><br /> "http://192.168.2.10/cam7.jpg",<br><br /> "http://192.168.2.10/cam8.jpg",<br><br /> "http://192.168.2.10/cam9.jpg" ];<br><br /> static var numurls = 9;<br><br /> private var parent:MovieClip;<br><br /> private var tf:TextField;<br><br /> private var mcTL:MovieClip;<br><br /> private var mcTR:MovieClip;<br><br /> private var mcBL:MovieClip;<br><br /> private var mcBR:MovieClip;<br><br /> static var count:Number = 0;<br><br /> static var urlidx:Number = 4;</p> <p> function UpdateText(mc:MovieClip) {<br><br /> // Add time based url extension to force non cached images<br><br /> var time:Date = new Date();<br><br /> var sec:String = String(time.getSeconds());<br><br /> var cnt:String = String(time.getMinutes()) + sec;<br><br /> var urlext:String = "?t=" + cnt;</p> <p> var mlMyLoader:MovieClipLoader = new MovieClipLoader();</p> <p> // rotate images and urls<br><br /> switch (count) {<br><br /> case 0: mlMyLoader.loadClip(urls[urlidx] + urlext, "mCam1"); break;<br><br /> case 1: mlMyLoader.loadClip(urls[urlidx] + urlext, "mCam2"); break;<br><br /> case 3: mlMyLoader.loadClip(urls[urlidx] + urlext, "mCam3"); break;<br><br /> case 2: mlMyLoader.loadClip(urls[urlidx] + urlext, "mCam4"); break;<br><br /> }<br></p> <p> if (++count == 4) count = 0;<br><br /> if (++urlidx == numurls) urlidx = 0;</p> <p> delete mlMyLoader;<br><br /> }</p> <p> function Main(mc:MovieClip) {<br><br /> // save reference to main movieclip<br><br /> this.parent = mc;</p> <p> var mlMyLoader:MovieClipLoader = new MovieClipLoader();</p> <p> mcTL = mc.createEmptyMovieClip("mCam1", mc.getNextHighestDepth());<br><br /> mcTR = mc.createEmptyMovieClip("mCam2", mc.getNextHighestDepth());<br><br /> mcBL = mc.createEmptyMovieClip("mCam3", mc.getNextHighestDepth());<br><br /> mcBR = mc.createEmptyMovieClip("mCam4", mc.getNextHighestDepth());</p></p> <p> // assume cam images are 640x480, scale by 1/4 for Chumby display<br><br /> mcTL._xscale = 25;<br><br /> mcTL._yscale = 25;<br><br /> mlMyLoader.loadClip(urls[0], "mCam1");</p> <p> mcTR._x = 160;<br><br /> mcTR._xscale = 25;<br><br /> mcTR._yscale = 25;<br><br /> mlMyLoader.loadClip(urls[1], "mCam2");</p> <p> mcBL._y = 120;<br><br /> mcBL._xscale = 25;<br><br /> mcBL._yscale = 25;<br><br /> mlMyLoader.loadClip(urls[2], "mCam3");</p> <p> mcBR._x = 160;<br><br /> mcBR._y = 120;<br><br /> mcBR._xscale = 25;<br><br /> mcBR._yscale = 25;<br><br /> mlMyLoader.loadClip(urls[3], "mCam4");</p> <p> delete mlMyLoader;</p> <p> var mytimer = setInterval(UpdateText, 1000, mc);<br /> }</p> <p> static function main(mc:MovieClip) {<br><br /> var app = new Main(mc);<br><br /> }<br><br /> }<br><br />