[[ACTIONS LAYER]] //get the default camera //change your Default camera using the Flash Player Settings. cam=Camera.get() //this event is called whenever permission to access the local camera, is accepted or denied by the user cam.onStatus=function(e) { //if we are given permission if(e.code == "Camera.Unmuted") { //start the application initialize() } else { System.showSettings(3) } } //if there are no Cameras if(cam == null) { System.showSettings(3) } else { output.attachVideo(cam) } **************************************************************** [[FUNCTIONS LAYER]] import flash.display.BitmapData import flash.geom.* function initialize() { //create an array that will be the fading image cue list=new Array() //create an identity matrix m=new Matrix() //scale the transformation matrix to match the scale of the Video object on stage m.scale((output._xscale/100),(output._yscale/100)) //create a bitmap object in memory that is the same size as the Video object on stage now=new BitmapData(output._width,output._height) //create a bitmap object in memory to hold a layered bitmap from the fading image cue out=new BitmapData(output._width,output._height) //create a movieclip that can display the final bitmap this.createEmptyMovieClip("output_mc",this.getNextHighestDepth()) //attach the bitmap inside the holder movie clip output_mc.attachBitmap(out,1) //position it to the right of the live Webcam feed output_mc._x=output._width output_mc._y=output._y //call the snap function every 1/10th of a second setInterval(this,"snap",100) } //capture a freezeframe from the webcam and copy it, called regularly do detect movement function snap() { //draw the movieclip into the bitmapdata object object with the scaled transformation matrix now.draw(output,m) //copy the current freezeframe done=now.clone() //now draw the previous freezeframe ("BEFORE"!) on top of the current frameframe and apply the 'difference' blendmode done.draw(before,m,null,"difference") //over-write the previous contents of the bitmap done.threshold(done,done.rectangle,done.rectangle.topLeft,">",0xFF111111,0xFF00FF00,0x00FFFFFF,false) //clear the out bitmap object so we can start a fresh out.fillRect(out.rectangle,0xFF000000) //copy the current bitmap and save it for the next time this function is called before=now.clone() //loop through each bitmap in the fading image cue w=done.width; h=done.height; out.draw(done, m, difference, null, out.rectangle) }