Home > Java > javaTutorial > How Flash8 calls the camera to realize the photo taking function

How Flash8 calls the camera to realize the photo taking function

PHP中文网
Release: 2017-08-19 10:21:00
Original
2751 people have browsed it

This article introduces how to use Actionscript3.0 to operate the computer camera and realize the camera function

The code has been tested by me and is available for reference.

1. Create three layers,

2. Ctrl+L to open the component library, right-click in the blank space, select New Video, name it whatever you want, and select the second video (subject to ActionScript control).
3. Drag the video component into the first layer, find the position, adjust the size, and set the video name to my_video in the properties

4. Insert the following into the first frame of the second layer Code:

//导入类
import flash.display.BitmapData;
import flash.filters.BlurFilter;
//获取摄像
var cam:Camera = Camera.get();
var my_video:Video;
my_video.attachVideo(cam);
//设置模糊对象
var blur:BlurFilter = new BlurFilter(10, 10, 2);
var myFilters = [blur];
blurbutton.onPress = makeBlur;
//定义模糊函数
function makeBlur() {
capture();
}
//获取截图函数
function capture() {
var snap:BitmapData = new BitmapData(my_video._width, my_video._height);
snap.draw(my_video);
var temp:MovieClip = createEmptyMovieClip("bitmap_mc", 0);
temp._x = 200;
temp._y = 65;
temp._xscale = 100;
temp._yscale = 100;
temp.attachBitmap(snap, 1);
temp.filters = myFilters;
}
stop();
Copy after login

5. Create a new video clip, drag it to the third layer, and set its instance name to blurbutton

6. Test

This article is written by Provided by PHP Chinese website, the code introduces the outdated flash technology, for reference only

Article address: http://www.php.cn/java-article-377109.html

To learn programming, come to PHP Chinese website www.php.cn

The above is the detailed content of How Flash8 calls the camera to realize the photo taking function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template