WEB CAM IN AS3 WITH COOL FILTER as3 |
Very basic tutorial that will show you how to create aplication with web cam and very simple yet cool looking video filter. Ofcourse this require you to have web camera on connected to your pc.
At the end you shold get something like this:
Open new actionscript 3.0 file. Set the resolution of the stage to 350px x 250px. We start by creating the filter. If you dont want it just skip this part and just copy the actionscript code. Now to the filter part.
Create rectangle of the size of the stage and paint it so it looks like chess board. Convert it to movieclip and under display option choose Blending:Difference.
![]() Now open actions window and write in the following actionscript code: var cam:Camera = Camera.getCamera(); var vid:Video = new Video(350,250); cam.setMode(350,250,30); vid.attachCamera(cam); vid.x=0; vid.y=0; addChild(vid); setChildIndex(vid, 0);
First line creates new cam variable that stores your web camera input. Second line is variable for new video with the resolution of 350px x 250px. Third line sets the mode for our
web cam setMode(width , height , frame rate).Fourth line adds our web cam input to the new video variable. Lines 5 and 6 moves the video to 0,0 position on stage. Line 8 adds this video with web cam on the stage.
The very last line arrange the video. In this case the 0 means its send all the way to the back so the video filter is above it and visible. Again if you dont want to use the video filter you can skip the last line.
|