gpt4 book ai didi

apache-flex - 弹性 : how to change the volume of an EMBEDDED sound?

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

搜索如何改变声音的音量,我总是很烦snd=new Sound(URLRequest) ,后跟 snd.setVolume(val) .哦,很好,但我的声音不是 URLRequest,而是嵌入。

我做了很多随机尝试(1)无济于事。我应该怎么做呢?

(1) 包括将我的类转换为 Sound,使用 embed 类作为参数创建 Sound,创建 SoundTransform 并将其设置为 channel 等。

最佳答案

像这样实例化您的嵌入式类:

[Embed(source="MySound.mp3")]
public var soundClass:Class;


protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var smallSound:Sound = new soundClass() as Sound;
var trans:SoundTransform = new SoundTransform(.01);
smallSound.play(0,0,trans);
}

更新:

如果您真正想知道的是如果声音已经在播放,如何更改音量:
[Embed(source="MySound.mp3")]
public var soundClass:Class;
public var smallSound : Sound;
public var vol : Number = 0.01;
public var trans : SoundTransform;

public var chan : SoundChannel = new SoundChannel();

protected function application1_creationCompleteHandler(event:FlexEvent):void {
smallSound = new soundClass() as Sound;
trans = new SoundTransform(vol);
chan = smallSound.play(0,0,trans);
}

protected function volUp_clickHandler(event:MouseEvent):void {
vol += .1;
trans = new SoundTransform(vol);

chan.soundTransform = trans;
}

关于apache-flex - 弹性 : how to change the volume of an EMBEDDED sound?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5094192/

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