window.runtime 属性window.runtime.flash.events.SampleDataEvent
继承SampleDataEvent Inheritance Event Inheritance Object
运行时版本:  1.5

当播放器请求新的音频数据时调度。

在需要管理动态生成的音频时使用此事件。在此环境中,Sound 对象实际上并不包含声音数据。相反,该对象将用作声音数据的套接字,声音数据通过使用您分配给此事件的函数流入该对象。

在您的函数中使用 ByteArray.writeFloat() 方法来写入到包含要播放的已采样数据的 ByteArray 对象 (event.data)。

当您调用 Sound.play() 时,播放器将开始调用事件处理程序并请求包含声音样本的数据块。播放声音时播放器将继续发送事件,直至您停止提供数据或调用 SoundChannel.stop()

事件的滞后时间在不同的平台上会有所变化,并且在将来版本的 Flash Player 中也将改变。请不要依赖某个特定的滞后时间,而应计算出相应的滞后时间。若要在 ActionScript 中计算滞后时间,请使用公式:((SampleDataEvent.position/44.1) - SoundChannelObject.position)

SampleDataEvent 对象中提供 2048 到 8192 个样本。为了获得最佳性能,请尽可能多地提供样本。提供的样本越少,在播放过程中就越有可能出现单击和弹出事件。此行为在不同的平台上会有所不同,并且会在各种情况下发生。例如,当调整浏览器的大小时。在仅提供 2048 个样本时,您可能会编写可在一个平台上运行的代码,但在不同的平台上运行时,同样的代码可能无法正常工作。若要尽可能缩短滞后时间,请考虑允许用户选择数据量。

如果提供的样本数少于 2048 个,则 Flash Player 将播放其余的样本,然后停止声音,就像到达了声音文件的末尾,并生成 SoundComplete 事件。

也可以使用 Sound.extract() 方法来提取 Sound 对象中的数据,然后便可将数据写入到动态流以进行播放。

将此事件与 Sound 对象一起使用时,启用的其他 Sound 方法仅包括 Sound.extract()Sound.play()。调用任何其他方法或属性将导致“调用无效”异常。仍启用 SoundChannel 对象的所有方法和属性。

另请参见

Sound


属性
 属性定义方
 Inheritedbubbles : Boolean
[只读 (read-only)] 指示事件是否为冒泡事件。
Event
 Inheritedcancelable : Boolean
[只读 (read-only)] 指示是否可以阻止与事件相关联的行为。
Event
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 InheritedcurrentTarget : Object
[只读 (read-only)] 当前正在使用某个事件侦听器处理 Event 对象的对象。
Event
  data : ByteArray
音频流中的数据。
SampleDataEvent
 InheritedeventPhase : uint
[只读 (read-only)] 事件流中的当前阶段。
Event
  position : Number
数据在音频流中的位置。
SampleDataEvent
 Inheritedprototype : Object
[静态] 对类或函数对象的原型对象的引用。
Object
 Inheritedtarget : Object
[只读 (read-only)] 事件目标。
Event
 Inheritedtype : String
[只读 (read-only)] 事件的类型。
Event
公共方法
 方法定义方
  
SampleDataEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, theposition:Number = 0, thedata:ByteArray = null)
创建事件对象以包含有关音频数据事件的信息。
SampleDataEvent
  
[override] 创建 SampleDataEvent 对象的副本,并设置每个属性的值以匹配原始对象的属性值。
SampleDataEvent
 Inherited
formatToString(className:String, ... arguments):String
用于在自定义 ActionScript 3.0 Event 类中实现 toString() 方法的实用程序函数。
Event
 Inherited
hasOwnProperty(name:String):Boolean
指示对象是否已经定义了指定的属性。
Object
 Inherited
检查是否已对事件调用 preventDefault() 方法。
Event
 Inherited
isPrototypeOf(theClass:Object):Boolean
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
如果可以取消事件的默认行为,则取消该行为。
Event
 Inherited
propertyIsEnumerable(name:String):Boolean
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
设置循环操作动态属性的可用性。
Object
 Inherited
防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。
Event
 Inherited
防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。
Event
  
[override] 返回一个字符串,其中包含 SampleDataEvent 对象的所有属性。
SampleDataEvent
 Inherited
valueOf():Object
返回指定对象的原始值。
Object
常量
 常量定义方
 InheritedACTIVATE : String = "activate"
[静态] ACTIVATE 常量定义 activate 事件对象的 type 属性的值。
Event
 InheritedADDED : String = "added"
[静态] Event.ADDED 常量定义 added 事件对象的 type 属性值。
Event
 InheritedADDED_TO_STAGE : String = "addedToStage"
[静态] Event.ADDED_TO_STAGE 常量定义 addedToStage 事件对象的 type 属性值。
Event
 InheritedCANCEL : String = "cancel"
[静态] Event.CANCEL 常量定义 cancel 事件对象的 type 属性的值。
Event
 InheritedCHANGE : String = "change"
[静态] Event.CHANGE 常量定义 change 事件对象的 type 属性值。
Event
 InheritedCLEAR : String = "clear"
[静态] Event.CLEAR 常量定义 clear 事件对象的 type 属性的值。
Event
 InheritedCLOSE : String = "close"
[静态] Event.CLOSE 常量定义 close 事件对象的 type 属性的值。
Event
 InheritedCLOSING : String = "closing"
[静态] Event.CLOSING 常量定义 closing 事件对象的 type 属性值。
Event
 InheritedCOMPLETE : String = "complete"
[静态] Event.COMPLETE 常量定义 complete 事件对象的 type 属性值。
Event
 InheritedCONNECT : String = "connect"
[静态] Event.CONNECT 常量定义 connect 事件对象的 type 属性值。
Event
 InheritedCOPY : String = "copy"
[静态] 定义 copy 事件对象的 type 属性值。
Event
 InheritedCUT : String = "cut"
[静态] 定义 cut 事件对象的 type 属性值。
Event
 InheritedDEACTIVATE : String = "deactivate"
[静态] Event.DEACTIVATE 常量定义 deactivate 事件对象的 type 属性值。
Event
 InheritedDISPLAYING : String = "displaying"
[静态] Event.DISPLAYING 常量定义 displaying 事件对象的 type 属性值。
Event
 InheritedENTER_FRAME : String = "enterFrame"
[静态] Event.ENTER_FRAME 常量定义 enterFrame 事件对象的 type 属性值。
Event
 InheritedEXIT_FRAME : String = "exitFrame"
[静态] Event.EXIT_FRAME 常量定义 exitFrame 事件对象的 type 属性的值。
Event
 InheritedEXITING : String = "exiting"
[静态] Event.EXITING 常量定义 exiting 事件对象的 type 属性值。
Event
 InheritedFRAME_CONSTRUCTED : String = "frameConstructed"
[静态] Event.FRAME_CONSTRUCTED 常量定义 frameConstructed 事件对象的 type 属性的值。
Event
 InheritedFULLSCREEN : String = "fullScreen"
[静态] Event.FULL_SCREEN 常量定义 fullScreen 事件对象的 type 属性值。
Event
 InheritedHTML_BOUNDS_CHANGE : String = "htmlBoundsChange"
[静态] Event.HTML_BOUNDS_CHANGE 常量定义 htmlBoundsChange 事件对象的 type 属性值。
Event
 InheritedHTML_DOM_INITIALIZE : String = "htmlDOMInitialize"
[静态] Event.HTML_DOM_INITIALIZE 常量定义 htmlDOMInitialize 事件对象的 type 属性值。
Event
 InheritedHTML_RENDER : String = "htmlRender"
[静态] Event.HTML_RENDER 常量定义 htmlRender 事件对象的 type 属性值。
Event
 InheritedID3 : String = "id3"
[静态] Event.ID3 常量定义 id3 事件对象的 type 属性值。
Event
 InheritedINIT : String = "init"
[静态] Event.INIT 常量定义 init 事件对象的 type 属性值。
Event
 InheritedLOCATION_CHANGE : String = "locationChange"
[静态] Event.LOCATION_CHANGE 常量定义 locationChange 事件对象的 type 属性值。
Event
 InheritedMOUSE_LEAVE : String = "mouseLeave"
[静态] Event.MOUSE_LEAVE 常量定义 mouseLeave 事件对象的 type 属性值。
Event
 InheritedNETWORK_CHANGE : String = "networkChange"
[静态] Event.NETWORK_CHANGE 常量定义 networkChange 事件对象的 type 属性值。
Event
 InheritedOPEN : String = "open"
[静态] Event.OPEN 常量用于定义 open 事件对象的 type 属性值。
Event
 InheritedPASTE : String = "paste"
[静态] Event.PASTE 常量定义 paste 事件对象的 type 属性的值。
Event
 InheritedREMOVED : String = "removed"
[静态] Event.REMOVED 常量定义 removed 事件对象的 type 属性值。
Event
 InheritedREMOVED_FROM_STAGE : String = "removedFromStage"
[静态] Event.REMOVED_FROM_STAGE 常量定义 removedFromStage 事件对象的 type 属性值。
Event
 InheritedRENDER : String = "render"
[静态] Event.RENDER 常量定义 render 事件对象的 type 属性的值。
Event
 InheritedRESIZE : String = "resize"
[静态] Event.RESIZE 常量定义 resize 事件对象的 type 属性的值。
Event
  SAMPLE_DATA : String = "sampleData"
[静态] 定义 SampleDataEvent 事件对象的 type 属性值。
SampleDataEvent
 InheritedSCROLL : String = "scroll"
[静态] Event.SCROLL 常量定义 scroll 事件对象的 type 属性值。
Event
 InheritedSELECT : String = "select"
[静态] Event.SELECT 常量定义 select 事件对象的 type 属性的值。
Event
 InheritedSELECT_ALL : String = "selectAll"
[静态] Event.SELECT_ALL 常量定义 selectAll 事件对象的 type 属性的值。
Event
 InheritedSOUND_COMPLETE : String = "soundComplete"
[静态] Event.SOUND_COMPLETE 常量定义 soundComplete 事件对象的 type 属性值。
Event
 InheritedTAB_CHILDREN_CHANGE : String = "tabChildrenChange"
[静态] Event.TAB_CHILDREN_CHANGE 常量定义 tabChildrenChange 事件对象的 type 属性值。
Event
 InheritedTAB_ENABLED_CHANGE : String = "tabEnabledChange"
[静态] Event.TAB_ENABLED_CHANGE 常量定义 tabEnabledChange 事件对象的 type 属性值。
Event
 InheritedTAB_INDEX_CHANGE : String = "tabIndexChange"
[静态] Event.TAB_INDEX_CHANGE 常量定义 tabIndexChange 事件对象的 type 属性值。
Event
 InheritedUNLOAD : String = "unload"
[静态] Event.UNLOAD 常量定义 unload 事件对象的 type 属性值。
Event
 InheritedUSER_IDLE : String = "userIdle"
[静态] Event.USER_IDLE 常量定义 userIdle 事件对象的 type 属性值。
Event
 InheritedUSER_PRESENT : String = "userPresent"
[静态] Event.USER_PRESENT 常量定义 userPresent 事件对象的 type 属性值。
Event
属性详细信息
data属性
data:ByteArray
运行时版本:  1.5

音频流中的数据。

position属性 
position:Number
运行时版本:  1.5

数据在音频流中的位置。

构造函数详细信息
SampleDataEvent()构造函数
function SampleDataEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, theposition:Number = 0, thedata:ByteArray = null)
运行时版本:  1.5

创建事件对象以包含有关音频数据事件的信息。将 Event 对象作为参数传递给事件侦听器。

参数
type:String — 事件的类型。此值为 Event.SAMPLE_DATA
 
bubbles:Boolean (default = false) — 确定 Event 对象是否参与事件流的冒泡阶段。
 
cancelable:Boolean (default = false) — 确定是否可以取消 Event 对象。
 
theposition:Number (default = 0) — 数据在音频流中的位置。
 
thedata:ByteArray (default = null) — 数据的字节数组。
方法详细信息
clone()方法
function clone():Event
运行时版本:  1.5

创建 SampleDataEvent 对象的副本,并设置每个属性的值以匹配原始对象的属性值。

返回
Event — 一个新的 SampleDataEvent 对象,其属性值与原始对象的属性值匹配。
toString()方法 
function toString():String
运行时版本:  1.5

返回一个字符串,其中包含 SampleDataEvent 对象的所有属性。字符串的格式如下:

[SampleDataEvent type=value bubbles=value cancelable=value theposition=value thedata=value]

返回
String — 包含 SampleDataEvent 对象的所有属性的字符串。
常量详细信息
SAMPLE_DATA常量
static const SAMPLE_DATA:String = "sampleData"
运行时版本:  1.5

定义 SampleDataEvent 事件对象的 type 属性值。

此事件具有以下属性:

属性
bubblesfalse
cancelablefalse;没有要取消的默认行为。
position从中提供音频数据的点。

另请参见