用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: 正在从服务器检索数据...
正在从服务器检索数据...
mx.core 

SoundAsset  - AS3 Flex

mx.core
public class SoundAsset
继承SoundAsset Inheritance Sound Inheritance EventDispatcher Inheritance Object
实现 IFlexAsset

语言版本: ActionScript 3.0
产品版本: Flex 3
运行时版本: Flash Player 9, AIR 1.1

SoundAsset 是 flash.media.Sound 类的子类,代表您在 Flex 应用程序中嵌入的声音。

可以嵌入 MP3 文件格式的声音。您还可以嵌入由 Flash 生成的 SWF 文件中的声音元件。在这两种情况下,MXML 编译器自动生成可扩展 SoundAsset 以代表嵌入的声音数据的类。

编写 Flex 应用程序时,您通常不必直接使用 SoundAsset 类。例如,通过编写以下代码即可嵌入 MP3 文件,然后在 SoundEffect 中使用该文件:

  <mx:SoundEffect id="beep" source="@Embed(source='Beep.mp3')"/>

不必了解 MXML 编译器已为您创建了 SoundAsset 的子类。

不过,了解在 ActionScript 级别发生的操作可能会有用。要在 ActionScript 中嵌入位图,请声明类型为 Class 的变量,并为其指定 [Embed] 元数据。例如,您可以通过以下方式嵌入 MP3 文件:

  [Bindable]
  [Embed(source="Beep.mp3")]
  private var beepClass:Class;

MXML 编译器识别出 .mp3 扩展名,将 MP3 数据转码为播放器使用的声音格式,自动生成 SoundAsset 类的子类,并将您的变量设置为对此自动生成类的引用。然后,您可以使用此类引用通过 new 运算符创建 SoundAsset 实例,还可以在这些实例上使用 Sound 类的 API:

    var beepSound:SoundAsset = SoundAsset(new beepClass());
    beepSound.play();

但是,您很少需要自己创建 SoundAsset 实例,因为可以直接将 sound-related 属性和样式设置为 sound-producing 类,之后组件将根据需要创建声音实例。例如,要使用 SoundEffect 播放此声音,则可以将 SoundEffect 的 source 属性设置为 beepClass。在 MXML 中,您可以按照以下方法执行此操作:

  <mx:SoundEffect id="beepEffect" source="{beepClass}"/>



公共属性
 属性由以下参数定义
 InheritedbytesLoaded : uint
[只读] 返回此声音对象中当前可用的字节数。
Sound
 InheritedbytesTotal : int
[只读] 返回此声音对象中总的字节数。
Sound
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 Inheritedid3 : ID3Info
[只读] 提供对作为 MP3 文件一部分的元数据的访问。
Sound
 InheritedisBuffering : Boolean
[只读] 返回外部 MP3 文件的缓冲状态。
Sound
 InheritedisURLInaccessible : Boolean
[只读] 表示 Sound.url 属性是否已截断。
Sound
 Inheritedlength : Number
[只读] 当前声音的长度(以毫秒为单位)。
Sound
 Inheritedurl : String
[只读] 从中加载此声音的 URL。
Sound
公共方法
 方法由以下参数定义
  
构造函数。
SoundAsset
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
 Inherited
关闭该流,从而停止所有数据的下载。
Sound
 Inherited
将事件调度到事件流中。
EventDispatcher
 Inherited
extract(target:ByteArray, length:Number, startPosition:Number = -1):Number
从 Sound 对象提取原始声音数据。
Sound
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
表示对象是否已经定义了指定的属性。
Object
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
load(stream:URLRequest, context:SoundLoaderContext = null):void
启动从指定 URL 加载外部 MP3 文件的过程。
Sound
 Inherited
将 ByteArray 对象中的 MP3 声音数据加载到 Sound 对象中。
Sound
 Inherited
loadPCMFromByteArray(bytes:ByteArray, samples:uint, format:String = "float", stereo:Boolean = true, sampleRate:Number = 44100.0):void
将 ByteArray 对象中的 PCM 32 位浮点声音数据加载到 Sound 对象中。
Sound
 Inherited
play(startTime:Number = 0, loops:int = 0, sndTransform:flash.media:SoundTransform = null):SoundChannel
生成一个新的 SoundChannel 对象来播放该声音。
Sound
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。
EventDispatcher
事件
 事件 摘要 由以下参数定义
 Inherited[广播事件] Flash Player 或 AIR 应用程序获得操作系统焦点并变为活动状态时将调度此事件。EventDispatcher
 Inherited成功加载数据后调度。Sound
 Inherited[广播事件] Flash Player 或 AIR 应用程序失去操作系统焦点并变为非活动状态时将调度此事件。EventDispatcher
 Inherited在存在可用于 MP3 声音的 ID3 数据时由 Sound 对象调度。Sound
 Inherited在出现输入/输出错误并由此导致加载操作失败时调度。Sound
 Inherited在加载操作开始时调度。Sound
 Inherited在加载操作进行过程中接收到数据时调度。Sound
 Inherited在运行时请求新音频数据时调度。Sound
构造函数详细信息

SoundAsset

()构造函数
public function SoundAsset()

语言版本: ActionScript 3.0
产品版本: Flex 3
运行时版本: Flash Player 9, AIR 1.1

构造函数。





[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。