问题描述
我想用PNG EN codeR救我的图形,而我得到两个错误。
I am trying to save my graphics using the PNG encoder, and I get two errors.
Scene 1, Layer 'canvas', Frame 2, Line 42, Column 12 1172: Definition PNGEncoder could not be found.
Scene 1, Layer 'canvas', Frame 2, Line 965, Column 24 1120: Access of undefined property PNGEncoder.
下面是所有code周转节省:
Here is all the code revolving saving:
import PNGEncoder; [Recieves the first error]
function export():void
{
var bmd:BitmapData = new BitmapData(board.width, board.height);
bmd.draw(board);
var ba:ByteArray = PNGEncoder.encode(bmd); [Recieves the second error]
var file:FileReference = new FileReference();
file.save(ba, "MyDrawing.png");
}
saveButton.addEventListener(MouseEvent.CLICK,save)
function save(e:MouseEvent):void
{
export();
}
我是从一个教程这个code,所以我不能太相信它是格式化的权利。啧啧称,PNGEn codeR是进口,但根据Flash CS3中它不是。有人可以帮我理顺了这一点?我贴上了部分给我的错误,谢谢。
I got this code from a tutorial, so I can't be too sure it is formated right. The tut said that PNGEncoder was an import but according to flash cs3 it is not. Can someone help me straighten this out? I labeled the parts giving me an error, thanks.
推荐答案
您需要下载 PNG恩codeR 并设置闪光灯知道在哪里可以找到新的库(以下过程可以用于任何其它外部下载的深港西部通道的,你需要在今后的使用)
You need to download the PNG Encoder and setup Flash to know where to find the new library (the process below can be used for any other externally downloaded SWC's you need to use in future)
1)创建一个名为Flash_Addons新的文件夹(路径是 C:\ Flash_Addons \它只是让你开始,现在,以后更改设置为prefered文件夹名称/位置)
1) Create a new folder called Flash_Addons(the path would be C:\Flash_Addons\ it's just to get you started for now, later change the setup to a prefered folder name/location)
2)下载 AS3 corelib的(下载ZIP选项底部/右侧
2) Download the AS3 CoreLib (the "Download ZIP" option at bottom/right-hand side
3)在Zip是一个文件夹(我认为它称为的as3corelib - 0.93)复制到你的Flash_Addons文件夹,以便它现在是一个子文件夹。
3) Inside the Zip is a folder (I think its called "as3corelib-.93") copy that to your Flash_Addons folder so it's now a sub-folder.
4)我们告诉Flash哪里可以找到它。在你的CS得的修改 - > preferences ( CTRL + U快捷方式),并在类别列表中点击动作,那么显示的时候点击的ActionScript 3.0设置
现在,您将看到三个框(来源路径/库路径/外部路径)。
4) Now to tell Flash where to find it.. In your CS got to Edit-->Preferences (CTRL+U shortcut) and click on "ActionScript" in Category list then when shown click ActionScript 3.0 Settings
Now you will see three boxes (Source path/ Library path/ External path).
(这些在下面,点击 + 添加新条目,然后键入路径,或单击文件夹图标浏览)
源路径::您希望它来添加。C:\ Flash_Addons \
库路径::您希望它来添加。C:\ Flash_Addons \的as3corelib-0.93 \ lib中
(注:lib目录文件夹中包含了实际as3corelib.SWC文件,这就是为什么我们把直接的路径是当你想添加任何新的SWC库只需添加路径条目列表(例如):
C:\ Flash_Addons \的as3corelib-0.93 \ lib中
C:\ Flash_Addons \ Useful_Library_Folder_of_SWC_file \
等等...等等。
(for these below, click "+" to add new entry, then either type path or click the folder icon to browse)
Source path: You want it to add.. C:\Flash_Addons\
Library path: You want it to add.. C:\Flash_Addons\as3corelib-.93\lib
(note: the "lib" folder contains the actual as3corelib.SWC file, that's why we put direct path to it. When you want to add any new SWC library just add path to the list of entries (example):
C:\Flash_Addons\as3corelib-.93\lib
C:\Flash_Addons\Useful_Library_Folder_of_SWC_file\
etc... etc..
现在,你已经准备好出口PNG ..
Now you're ready to export PNG..
import com.adobe.images.PNGEncoder; //fixes the errors
saveButton.addEventListener(MouseEvent.CLICK, save)
function save(e:MouseEvent):void
{ export(); }
function export():void
{
var bmd:BitmapData = new BitmapData(board.width, board.height);
bmd.draw(board);
var ba:ByteArray = PNGEncoder.encode(bmd);
var file:FileReference = new FileReference();
file.save(ba, "MyDrawing.png");
}
这篇关于AS3 PNGEn codeR错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!