我已经写了足够的代码来预览闪存中的网络摄像头视频。

现在,我想以10秒间隔捕获图像。

这是我的代码:

import flash.display.BitmapData
import flash.geom.Matrix
import com.adobe.images.JPGEncoder;
import flash.net.FileReference;

//get the default camera
//change your Default camera using the Flash Player Settings.
cam=Camera.get()
//this event is called whenever permission to access the local camera, is accepted or denied by the user
cam.onStatus=function(e)
{
    //if we are given permission
    if(e.code == "Camera.Unmuted")
    {
        //start the application
        initialize()
    }
    else
    {
        System.showSettings(3)
    }
}

var snapshot:BitmapData=new BitmapData(cam._width,cam._height);

function takeSnapshot()
{
    snapshot.draw(cam,new Matrix());
}


//if there are no Cameras
if(cam == null)
{
    System.showSettings(3)
}
else
{
    cam.setMode(1024, 768, 30);
    cam.setQuality(10000,0);
    output.attachVideo(cam);
    setInterval(this,"takeSnapshot",1000);
}
.

请任何帮助?

我是一个总闪存的newbie。

谢谢, rishi。

有帮助吗?

解决方案

如果要将其保存到用户的磁盘记住,请记住,由于出于安全原因,您无法自动完成,因此只能在特定用户操作之后使用filereference类的保存()方法(单击,Mousedown和我猜按键)。在您拥有BitMapData后,您需要 http://code.google.com/p / as3corelib / 对您的IMG进行编码并将其保存到磁盘。这样的东西:

    var fileBrowser:FileReference = new FileReference();

    var bd:BitmapData = new BitmapData(imageContainer.width, imageContainer.height, false, 0xFFFFFF);

    bd.draw(imageContainer);

    var encoder:JPGEncoder = new JPGEncoder(35);

    var bytes:ByteArray = encoder.encode(bd);

    fileBrowser.save(bytes);
.

看看这里的Filereference Doc http://help.adobe.com/en_us/as3lcr/flash_10.0/flash/net/filereference.html 所以你看你还能用它做什么。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top