Flash IDE 能够嵌入多种类型的未压缩声音文件,包括 wav,并在发布时提供可选的压缩。
然而,[Embed] 标签似乎只允许嵌入 mp3 文件。嵌入未压缩的 wav 文件真的不可能,还是我错过了一些神奇的、未记录的 mimeType?
我希望是这样的:
[Embed source="../../audio/wibble.wav" mimeType="audio/wav"]
...但我明白了
no transcoder registered for mimeType 'audio/wav'
可以将 wav 或其他格式作为八位字节流嵌入并在运行时解析,但我认为这是非常繁重的。
我很惊讶即使 Flash IDE 可以嵌入未压缩的声音数据,[Embed] 也不能,因为 swf 规范可以包含未压缩的声音数据。
有接类人吗?
最佳答案
来自 LiveDocs - Basics of working with sound :
[...] Although there are various sound file formats used to encode digital audio, ActionScript 3.0, Flash Player and AIR support sound files that are stored in the mp3 format. They cannot directly load or play sound files in other formats like WAV or AIFF. [...]
但显然有一个解决方法。查看 this thread from actionscript.org 中的帖子 #3 :
Replying to myself in case anyone has the same question in the future and is searching for an answer.
I couldn't find any direct support for embedding WAV files in a Flex Builder 3 / ActionScript 3 application. What I did try and was delighted to see it works is to create a Flash Movie in Flash CS 3 (you will need to own that or get an evaluation) and import your sounds to the library and link them to be exported by ActionScript. Export the Flash CS3 project to a SWF movie and save it in your project (I added it to a "lib folder").
Your ActionScript code to create and play the sound should be:
[Embed(source="lib/Sounds.swf", symbol="BigShipSound")] private static var BigShipSound: Class; ... var bigShipSound : Sound = BigShipSound as Sound; bigShipSound.play(0, 20);
关于flash - 在 AS3 Flash/Flex 项目中嵌入 wav 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2825543/