Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


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

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


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

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


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: 4625
» 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