2010-07-17 141 views
0

我是一个总的Flash新手。我刚刚安装了Flash CS5并运行此代码。无法加载类或接口'flash.utils.ByteArray'

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设置?

回答

0

听起来就像你没有使用AS3导出,当你需要导出时,一定要选择“Actionscript 3”作为语言。我只是尝试使用CS3(但我怀疑CS5在这方面改变了什么),并且一切正常。

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

+0

在发布设置中,我没有在下拉菜单中获取AS3。只有AS1和AS2可用。这似乎令人困惑。 – 2010-07-18 07:05:57

+1

@Hrishikesh Choudhari:我认为那就是它。我刚刚更新了我的答案,以便在项目级别更改它的步骤。我测试了创建一个AS2项目,然后使用成功的步骤将其更改为AS3。 – sdolan 2010-07-18 16:37:16

+0

@Hrishikesh Choudhari:你的目标是Flash lite还是flash 8及以下版本? – back2dos 2010-07-18 16:38:14