Flash 8 Camera Photo

Source: Internet
Author: User
A few days ago to help friends do a thing with the code.
Because for a long time does not do the Flash coding. So there is little concern about the new CALSS of Flash 8. But I've heard you say there is this function. I would like to find a section of the Internet tutorial or code to do. But found that there is no similar in China. You can only have plenty to do with your own hands.
Start procedure:
First step: Create a video component in the library, type selection: Video (subject to ActionScript control).
Step two: Drag the video symbol to the scene and resize it to the size you want. and named "My_video."
Step three: Glue the code below in the timeline.
var My_video:video;
my_video._x=100;
my_video._y=40;
var My_cam:camera = Camera.get ();
My_cam.setmode (180, 140, true);
My_video.attachvideo (My_cam);

Shutter.onrelease = function () {
Mybitmap = new Flash.display.BitmapData (180, +, true, 0);
Mybitmap.draw (My_video);
var tempobj = _root.createemptymovieclip ("photo", 100);
tempobj._x = 300;
Tempobj._y = 40;
Tempobj.attachbitmap (Mybitmap, 1, "always", true);
}; Testing found that there was a problem, the photograph only 160x120 area has the image. And the image is distorted. : Eek:
What's wrong with it? @#$%^&* (2 hour debug time omitted here ...)
Finally, it is found that my_video copying to the scene does not change the My_video.width and My_video.height properties, but the My_video._width and My_video._height properties. The original video element size is only 160x120. This is equivalent to the deformation of the my_video. The Bitmapdata.draw () does not take into account the deformation of the source element. In the official parlance:
Reference: The source MovieClip object does not use any of its staging transitions for this call. The source MovieClip object is considered to exist in a library or file, with no matrix conversions, no color conversions, and no blending modes. If you want to draw a movie clip by using the Transform property of the movie clip itself, you can use its transform object to pass various transformation properties.
I began to pay no attention to the solution he had given. I think since draw () does not consider the deformation of the source components, it can only be in the output of the photo components to do the deformation. So there was this code.
var My_video:video;
my_video._x=100;
my_video._y=40;
var My_cam:camera = Camera.get ();
My_cam.setmode (180, 140, true);
My_video.attachvideo (My_cam);

Shutter.onrelease = function () {
Mybitmap = new Flash.display.BitmapData (160, A, true, 0);
Mybitmap.draw (My_video);
var tempobj = _root.createemptymovieclip ("photo", 100);
tempobj._x = 300;
Tempobj._y = 40;
Tempobj._width= 180;
Tempobj._height = 240;
Tempobj.attachbitmap (Mybitmap, 1, "always", true);
The picture is the size you want, and the image is not deformed. But found that the image does not show the camera clear.
Thought for a moment, that is of course, draw () regardless of the deformation of the source element, draw when My_video was treated as 160x120 to draw. : Mad:
Can that change the size of the my_video by changing the My_video.width and My_video.height properties instead of deforming the My_video? No!!! The My_video.width and My_video.height properties are read-only.
Workaround:
The first step: the use of video editing software to create a 180x240 size of 1-jeong White mov video files.
Step two: Use the Macromedia Flash 8 video encoder to convert MOV videos to FLV video files.
Step three: Create a video component in the library, type selection: Embedding (synchronized with the timeline).
Step Fourth: Drag the video component to the scene and name it "My_video"
Testing found that My_video.width and My_video.height properties were 180x120. AHA: Cool:
Step Fifth: Glue the code below in the timeline.
var My_video:video;
My_video.clear ()
my_video._x=100;
my_video._y=40;
var My_cam:camera = Camera.get ();
My_cam.setmode (180, 140, true);
My_video.attachvideo (My_cam);

Shutter.onrelease = function () {
Mybitmap = new Flash.display.BitmapData (160, A, true, 0);
Mybitmap.draw (My_video);
var tempobj = _root.createemptymovieclip ("photo", 100);
tempobj._x = 300;
Tempobj._y = 40;
Tempobj._width= 180;
Tempobj._height = 240;
Tempobj.attachbitmap (Mybitmap, 1, "always", true);
Well, now all the problems are solved. ;)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.