0

我是一个完全的Flash新手。我刚刚安装了 Flash CS5 并运行了这段代码。

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

//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()
{   
    var i:Number=1;
    var fileRef:FileReference = new FileReference();
    snapshot.draw(cam,new Matrix());
    //saveImage();
     var encoder:JPGEncoder = new JPGEncoder();
     var ba:ByteArray = encoder.encode(bitmapData);
     fileRef.save(ba,"capture"+i+".jpg");
     i++;
}


//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",100);
}

然后在导出到 SWF 时出现错误:The class or interface 'flash.utils.ByteArray' could not be loaded.

这里有什么帮助吗?

我需要更改任何 AS3 设置吗?

4

1 回答 1

0

听起来您没有使用 AS3 导出,当您必须导出时,请务必选择“Actionscript 3”作为语言。我刚刚使用 CS3 进行了尝试(但我怀疑 CS5 在这方面有什么改变),一切正常。

要将项目更改为 AS3(在 CS3 中):转到文件 > 发布设置... > 单击 flash 选项卡 > 将 ActionScript 版本更改为“Actionscript 3.0”。

于 2010-07-17T15:56:55.153 回答