收藏本站 | 广告设计 | 设计素材 | 教程 | ppt素材 | 中职 | 范文 | 常识 | 学习方法 | 作文  
订阅
首页
高考试题中考试卷学习方法范文写作作文大全公务员考试英语考试中职教育生活常识评语大全
热门: 广告设计 设计素材 教程 ppt素材 自考试卷 计算机等级考试 财会类考试 建筑工程考试 医药类考试 考研 电脑学习 驾照考试 语录名言好词 周公解梦 偏方
当前位置:一路求学网文章频道平面设计教程Flash教程Flash实例教程:启动摄像头拍照动画

Flash实例教程:启动摄像头拍照动画

一路求学网 http://www.16qiuxue.com  阅览次数: 686次 11-23 13:08:40 

标签:flash教程制作,flash动画教程,flash教程下载,http://www.16qiuxue.com Flash实例教程:启动摄像头拍照动画,

Webjx核心提示:Flash实例教程:启动摄像头拍照动画.

Flash实例教程:启动摄像头拍照动画。大家请看效果:(如果你的机器的摄像头已经打开)

源文件下载:http://www.webjx.com/files/soft/1_090712084454.zip

1. Create a new flash file (Actionscript 3.0) and save it as captureWebcam.fla.

2. Rename ‘layer 1′ to ‘button’. Create a button on the stage, convert it to a movie clip and give it an instance name of capture_mc.

3. Create a new layer named ‘actions’ and with its first frame selected open the actions panel.
All that we are going to do now happens in the actionscript code.

4. First we initialize a webcam by attaching a camera to a Video object that we add to the stage:

1.var cam:Camera = Camera.getCamera();
2.var video:Video = new Video(320,240);
3.video.attachCamera(cam);
4.video.x = 20;
5.video.y = 20;
6.addChild(video);
5. Then, we need to use the Bitmap and BitmapData classes to store the image that we want to capture and display on the stage.
We start by importing the Bitmap and BitmapData classes:

1.import flash.display.Bitmap;
2.import flash.display.BitmapData;
6. Then create a new BitmapData object of the same proportions of the video object to store the BitmapData captured from the playing webcam.
And create a bitmap object to display the data from the BitmapData object and add it to the stage.

1.var bitmapData:BitmapData = new BitmapData(video.width,video.height);
2. 
3.var bitmap:Bitmap = new Bitmap(bitmapData);
4.bitmap.x = 360;
5.bitmap.y = 20;
6.addChild(bitmap);
7. Finally, after setting its buttonMode property to true, we add a Click event listener to our button. This event is handled by the captureImage function that draws the image that is currently displaying from the webcam into our bitmapData object.

1.capture_mc.buttonMode = true;
2.capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
3. 
4.function captureImage(e:MouseEvent):void {
5.   bitmapData.draw(video);
6.}
8. Here is the final code :

01.import flash.display.Bitmap;
02.import flash.display.BitmapData;
03. 
04.var cam:Camera = Camera.getCamera();
05.var video:Video = new Video(320,240);
06.video.attachCamera(cam);
07.video.x = 20;
08.video.y = 20;
09.addChild(video);
10. 
11.var bitmapData:BitmapData = new BitmapData(video.width,video.height);
12. 
13.var bitmap:Bitmap = new Bitmap(bitmapData);
14.bitmap.x = 360;
15.bitmap.y = 20;
16.addChild(bitmap);
17. 
18.capture_mc.buttonMode = true;
19.capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
20. 
21.function captureImage(e:MouseEvent):void {
22.   bitmapData.draw(video);
23.}

,Flash实例教程:启动摄像头拍照动画

网友评论>>

联系我们 | 网站地图 | 广告设计 | 设计素材 | 教程大全 | ppt素材 | 中职教育 | 范文大全 | 常识大全 | 学习方法 | 作文大全
一路求学网 版权所有. Copyright © - http://www.16qiuxue.com. All rights reserved.
学习方法_小学英语作文_驾照考试试题_幼儿园大班评语
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18