0
我试图建立一个流.mp3播放器在我的网站上运行各种声音文件。要做到这一点,我也跟着教程,包括代码模板:错误在行动脚本3在流媒体.mp3播放器
不过,我是否保留该模板的方向,以作者自己的声音文件或插入我自己的方向,以我的网上声音文件,我继续陷入我无法理解的ActionScript中的故障。
这些错误是:
1084:语法错误:之前应有rightparen _。
1086:语法错误:在右键盘之前预期分号。
当我尝试更正它们时,出现新错误。我无法确定声音文件是否正在加载;它绝对不会播放。音量滑块不起作用。
我没有找到一条线,看起来像它应该被注释掉,一个读取
在同一个地方
于是,我评论说出来开始。没有骰子。同样的错误。
在此先感谢您的任何建议。代码如下:
var musicPiece:Sound = new Sound(new URLRequest _
("http://blog.0tutor.com/JeffWofford_Trouble.mp3"));
var mySoundChannel:SoundChannel;
var isPlaying:Boolean = false;
to start at the same place
var pos:Number = 0;
play_btn.addEventListener(MouseEvent.CLICK, play_);
function play_(event:Event):void {
if (!isPlaying) {
mySoundChannel = musicPiece.play(pos);
isPlaying = true;
}
}
pause_btn.addEventListener(MouseEvent.CLICK, pause_);
function pause_(event:Event):void {
if (isPlaying) {
pos = mySoundChannel.position;
mySoundChannel.stop();
isPlaying = false;
}
}
stop_btn.addEventListener(MouseEvent.CLICK, stop_);
function stop_(event:Event):void {
if (mySoundChannel != null) {
mySoundChannel.stop();
pos = 0;
isPlaying = false;
}
}
var rectangle:Rectangle = new Rectangle(0,0,100,0);
var dragging:Boolean = false;
volume_mc.mySlider_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
function startDragging(event:Event):void {
volume_mc.mySlider_mc.startDrag(false,rectangle);
dragging = true;
volume_mc.mySlider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
}
function adjustVolume(event:Event):void {
var myVol:Number = volume_mc.mySlider_mc.x/100;
var mySoundTransform:SoundTransform = new SoundTransform(myVol);
if (mySoundChannel != null) {
mySoundChannel.soundTransform = mySoundTransform;
}
}
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
function stopDragging(event:Event):void {
if (dragging) {
dragging = false;
volume_mc.mySlider_mc.stopDrag();
}
}