2016-07-28 110 views
0

N.B.:我以不同於建議重複的方式調用聲音變量。這就是爲什麼它是不一樣的結構遵循這個問題的開始,

在我的應用程序,我已經使用了以下行嵌入音樂,在實際設備上通過Adobe AIR的運行:
停止嵌入音樂AS3

[Embed(source = '/inspiration.mp3')] 
     private var MyBack:Class; 
     private var back:Sound; 

後來,每當我想打它,我用下面的代碼:

back = (new MyBack()) as Sound; 
back.play(0,9999); 

它完美,問題是當我要停止音樂!我用過

back.stop(); 但它總是告訴我

1061: Call to a possibly undefined method stop through a reference with static type flash.media:Sound. 

我到底做錯了什麼?

+2

[Actionscript:在Adobe Flash CS4中停止聲音]的可能重複(http://stackoverflow.com/questions/8980789/actionscript-stopping-sound-in-adobe-flash-cs4) – null

回答

2

您應該存儲結果SoundChannel對象,然後使用該對象停止播放聲音。

var backPlaying:SoundChannel; 
.... 
backPlaying=back.play(0,9999); 
.... 
backPlaying.stop(); 

當然,讓這個backPlaying是持久的,又名在類中定義它放在一邊back