附加进度条
在下面的代码中,如何将进度条附加到声音上并指示其进度
<mx:Script>
<![CDATA[
import flash.media.*;
import flash.net.NetStream;
[Embed(source="new1.mp3")]
[Bindable]
public var sndCls:Class;
public var snd:Sound = new sndCls() as Sound;
public var sndChannel:SoundChannel;
private var recordingState:String = "idle";
public function playSound():void {
sndChannel=snd.play();
}
public function stopSound():void {
sndChannel.stop();
}
]]>
</mx:Script>
<mx:Button label="Play" click="playSound()" />
<mx:ProgressBar x="30" y="36" mode="manual" id="audioprogress" label=""
labelPlacement="bottom" width="220" fontSize="10"
fontWeight="normal"/>
</mx:Application>
In the following code how can the progress bar be attached to the sound and indicate it progress
<mx:Script>
<![CDATA[
import flash.media.*;
import flash.net.NetStream;
[Embed(source="new1.mp3")]
[Bindable]
public var sndCls:Class;
public var snd:Sound = new sndCls() as Sound;
public var sndChannel:SoundChannel;
private var recordingState:String = "idle";
public function playSound():void {
sndChannel=snd.play();
}
public function stopSound():void {
sndChannel.stop();
}
]]>
</mx:Script>
<mx:Button label="Play" click="playSound()" />
<mx:ProgressBar x="30" y="36" mode="manual" id="audioprogress" label=""
labelPlacement="bottom" width="220" fontSize="10"
fontWeight="normal"/>
</mx:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我知道的最简单的方法:
首先,在脚本部分创建两个函数:
然后,将
ProgressBar
更改为“轮询”模式并将源设置为this
非常适合我:)
注意 这些函数需要命名为
bytesLoaded
和bytesTotal
。它是ProgressBar
的“轮询”模式的一部分。如果您确实想要“手动”模式,则需要创建一个计时器,这比此机制更复杂。Here is the easiest way I know how:
First, create two functions in your script section:
Then, change your
ProgressBar
to the "polled" mode and set the source tothis
Works perfectly for me :)
NOTE The functions need to be named
bytesLoaded
andbytesTotal
. It is part of the "polling" mode of theProgressBar
. If you really want "manual" mode, you will need to create a timer, which is more complicated than this mechanism.