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 com.adobe.images.JPGEncoder could not be loaded

我已经从 code.google.com 的正确来源下载了 as3corelibrary,并将文件夹放在根目录中。现在它是 C:\wamp\www\com\adobe\images\JPGEncoder.as

是否有一些类路径或我必须设置的东西?

4

2 回答 2

0

是的,您需要设置类路径。

来自Adob​​e 帮助

设置应用程序级源路径:

  1. 选择编辑首选项 (Windows) 或 Flash > 首选项 (Macintosh),然后单击 ActionScript 类别。
  2. 单击 ActionScript 3.0 设置按钮并将路径添加到源路径列表。
于 2010-07-19T06:21:53.643 回答
0

看起来您已将 as3corelib 的代码放在 Web 服务器的根目录中 - 您必须将源代码放在源路径的根文件夹中。通常,这与您的 FLA 所在的文件夹相同。将该文件夹复制com到包含您的 FLA 的同一文件夹中,然后进行编译。

如果您的 FLA 位于同一个文件夹(Web 服务器的根目录)中,那么一开始是个坏主意 - 每个人都可以访问您的源代码。

于 2010-07-19T06:23:02.710 回答