適用於 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 is a subclass of the flash.media.Sound class which represents sounds that you embed in a Flex application.

The sound that you're embedding can be in an MP3 file. You can also embed a sound symbol that is in a SWF file produced by Flash. In both cases, the MXML compiler autogenerates a class that extends SoundAsset to represent the embedded sound data.

You don't generally have to use the SoundAsset class directly when you write a Flex application. For example, you can embed an MP3 file and use it in a SoundEffect simply by writing the following:

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

without having to understand that the MXML compiler has created a subclass of SoundAsset for you.

However, it may be useful to understand what is happening at the ActionScript level. To embed a bitmap in ActionScript, you declare a variable of type Class, and put [Embed] metadata on it. For example, you embed an MP3 file like this:

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

The MXML compiler sees the .mp3 extension, transcodes the MP3 data into the sound format that the player uses, autogenerates a subclass of the SoundAsset class, and sets your variable to be a reference to this autogenerated class. You can then use this class reference to create instances of the SoundAsset using the new operator, and you can use APIs of the Sound class on them:

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

However, you rarely need to create SoundAsset instances yourself because sound-related properties and styles can simply be set to a sound-producing class, and components will create sound instances as necessary. For example, to play this sound with a SoundEffect, you can set the SoundEffect's source property to beepClass. In MXML you could do this as follows:

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



公用屬性
 屬性定義自
 InheritedbytesLoaded : uint
[唯讀] 會傳回此 Sound 物件中目前可用的位元組數目。
Sound
 InheritedbytesTotal : int
[唯讀] 會傳回此 Sound 物件中的位元組總數。
Sound
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
 Inheritedid3 : ID3Info
[唯讀] 提供存取屬於 MP3 檔一部份的中繼資料。
Sound
 InheritedisBuffering : Boolean
[唯讀] 會傳回外部 MP3 檔的緩衝狀態。
Sound
 InheritedisURLInaccessible : Boolean
[唯讀] 指出 Sound.url 屬性是否曾被截斷。
Sound
 Inheritedlength : Number
[唯讀] 目前聲音的長度,以毫秒為單位。
Sound
 Inheritedurl : String
[唯讀] 從中載入此聲音的 URL。
Sound
公用方法
 方法定義自
  
Constructor.
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
將 MP3 聲音資料從 ByteArray 物件載入 Sound 物件。
Sound
 Inherited
loadPCMFromByteArray(bytes:ByteArray, samples:uint, format:String = "float", stereo:Boolean = true, sampleRate:Number = 44100.0):void
將 PCM 32 位元浮點聲音資料從 ByteArray 物件載入 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當 ID3 資料可用於 MP3 聲音時,由 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

Constructor.





[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。