A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5848 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


Random Links | Add your own Flash Related Links
Flash Tutorials 1277 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Webmaster (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Categories Flash MX 2004 Video Capturing!
Author: 123Webwizard | Website: http://webwizardinc.com |

 
Page 1
1

This is gonna be a short writing on the Video Capabilities of Flash Player 7! The two Classes (Actionscript 2.0) that make it possible in this verison are:

1. Camera Class
2. Video Class

The Camera class is primarily for use with Macromedia Flash Communication Server, but can be used in a limited fashion without the server and that is exactly what we are gonna do! Make a limited verison Flash Movie that can capture the video of a User who has a Web Cam attached to their PC. For example, to monitor a video feed from a web camera attached to your local system.

Here is a how the story goes!

We will do it "The Flash MX 2004 Way!". The package available with this tutorial contains three files:

Project File: wwinc_cam.flp
The .FLA Source File: mycam.fla
The .AS Actionscript Class File: MyVideoPlayer.as
The .SWF File: mycam.swf
the .HTML File: mycam.html

Project File:
*************
If you are a programmer and you've had a chance to work in Microsoft Visual Studios or JBuilder, you might have an idea of what this project file is. For non-programmers, well, its a schema file for a project. For example: Consider the file wwinc_cam.flp, it contains about the rest of the files in the our project, i.e. mycam.fla(src), mycam.swf (browser executable), so on and so forth.

The .AS Actionscript Class File:
********************************
Actionscript 2.0 defines a custom class, which lets you instantiate objects that share methods and properties that you define in a seperate .AS (actionscript file) or in the Actions Panel. But keywords such as static are on available in external Actionscript files.

For example, if you are developing an invoice-tracking system, you could create an invoice class that defines all the methods and properties that each invoice should have. You would then use the new invoice() command to create invoice objects i.e.:

var MyInvoice = new invoice();

The name of the class must be the same as the name of the external file that contains the class. For example, if you name a class MyVideoPlayer, the file that defines the class must be named MyVideoPlayer.as.

Going into the depth of class definitions is beyond the scope of this tutorial.

The MyVideoPlayer.as is our custom class file for this example. (This will also give you a hint of the Actionscript 2.0 custom class definitions). The code is well commented, so just read through it:

/******************************
Author: 123Webwizard
URL:    http://webwizardinc.com/
*******************************/
class MyVideoPlayer extends Object	{
 private var CamObj ;
 function MyVideoPlayer()	{	}
 /*Checks to see if the camera is installed or inuse!
 ***************************************************/
 public function hasCamera():Boolean{
 if (null != Camera.get()) {
 return true;
 }
 else {
 return false;
 }
 }
 /*our interface to the status field
 ***********************************/
 public function setStatus(str):Void	{
 _root.status.text += str;
 }
 /*this function actually captures the video stream
 **************************************************/
 public function captureVideo(vo):Void {
 var wwinc_Cam = Camera.get();
 /*Changing the default fps*/
 wwinc_Cam.setMode(280, 210, 30);
 /*Ensuring 4096 bytes/sec (4K/second) to send
 video with a minimum quality of 50 */
 wwinc_Cam.setQuality(4096, 50);
 vo.attachVideo(wwinc_Cam);
 /*Video should be smoothed (interpolated) as we have scaled
 the video object on the stage*/
 vo.smoothing = true;
 /*Exporting the Camera Object for further use*/
 setCameraObject(wwinc_Cam);
 }
 private function setCameraObject(co){
 this.CamObj = co;
 }
 public function getCamera():Camera{
 return this.CamObj;
 }
}
The .FLA Source File:
*********************
This is the Flash source file. It contains, the video object and a few calls to our own Actionscript Class (which would be next in this tutorial) i.e.:
/******************************
Author: 123Webwizard
URL:    http://webwizardinc.com/
*******************************/
var wwinc_mvp = new MyVideoPlayer();
with(wwinc_mvp){
 if(hasCamera()==true){
 setStatus("Capturing Devices(s) found...\n");
 captureVideo(myVideo_mc);
 }
 else{
 setStatus("No display devices are installed or in use!\n");
 }
}
/*Gets the status from Camera Object
************************************/
wwinc_mvp.getCamera().onStatus = function(msg) {
 if (msg.code == "Camera.Muted") {
 wwinc_mvp.setStatus("User has denied access to the camera!");
 }
 else{
 with(wwinc_mvp){
 setStatus("Video Device started...\n");
 setStatus("Frames per second: " + getCamera().fps + "\n");
 }
 }
};
wwinc_mvp.getCameraObject().onActivity = function(activity) {
 /*
 Event handler; invoked when the camera starts or stops
 detecting motion. If you want to respond to this
 event handler, you must punch in your statements here!!
 */
};
Other files:
************
These two files are self explainatory! ;-)
The .SWF File:                    mycam.swf
the .HTML File:                   mycam.html

Hope it was of any use to people... I tried to give the background and all within a small time range!

Have a ball!
123Webwizard.(Nasir Ali Sher)
http://webwizardinc.com/

1

» Level Advanced

Added: : 2003-09-25
Rating: 6.76 Votes: 29
Hits: 4621
» Author
I'm a Software Engineer and I do Flash MX is my spare time... I just love the tool!
» Download
Download the files used in this tutorial.
Download (32 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs