gpt4 book ai didi

actionscript-3 - Flex 4-嵌入多个MP3

转载 作者:行者123 更新时间:2023-12-03 00:07:16 25 4
gpt4 key购买 nike

我在带有启动和停止按钮的Flex应用程序中嵌入了mp3。使用此代码...

<fx:Script>
<![CDATA[
import mx.core.SoundAsset;
import flash.media.*;

[Embed(source="assets/pie-yan-knee.mp3")]
[Bindable]
public var Song:Class;

public var mySong:SoundAsset = new Song() as SoundAsset;
public var channel:SoundChannel;

public function playSound():void
{
stopSound();
channel = mySong.play();
}

public function stopSound():void
{
if ( channel != null ) channel.stop();
}
]]>
</fx:Script>

<s:HGroup>
<s:Button label="play" click="playSound();"/> <s:Button label="stop"
click="stopSound();"/>
</s:HGroup>

我希望有多个具有不同声音的实例。
我怎样才能做到这一点?

最佳答案

只需为每一个单独的类引用:

[Embed(source="assets/song1.mp3")] 
[Bindable]
public var Song1:Class;
[Embed(source="assets/song2.mp3")]
[Bindable]
public var Song2:Class;
[Embed(source="assets/song3.mp3")]
[Bindable]
public var Song3:Class;

关于actionscript-3 - Flex 4-嵌入多个MP3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8439493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com