flash - 在 AS3 Flash/Flex 项目中嵌入 wav 文件?

标签 flash actionscript-3 audio embed wav

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/

相关文章:

javascript - 延迟 CreateJS 动画时间轴

flash - flash如何打开端口来监听服务器请求?

actionscript-3 - 所有 Flash 游戏都可以轻松移植到 adobe air 以在 ios 上部署吗?

python - 在 Python 中静音/取消静音扬声器

ajax - 为什么我的音频文件无法在Firefox中播放?

linux - 使用 Linux 命令行从 WAV/RIFF 获取频谱

javascript - 通过颜色框内的 AS3 外部接口(interface)调用 javascript

c# - 使用 C# 在 SWF 中编辑 Sprite 变量

actionscript-3 - Action Script 3 .循环动画3次然后停止

flash - 等价于 as3 中的 md5(uniqid(mt_rand()))?