【问题标题】:Errors in Action Script 3 in streaming .mp3 player流式传输 .mp3 播放器中的动作脚本 3 中的错误
【发布时间】:2010-09-07 14:25:24
【问题描述】:

我正在尝试构建一个流媒体 .mp3 播放器来在我的网站上运行各种声音文件。为此,我遵循了包含代码模板的教程:

http://blog.0tutor.com/post.aspx?id=202&title=Mp3%20player%20with%20volume%20slider%20using%20Actionscript%203

但是,无论我将模板的方向保留到作者自己的声音文件中,还是将我自己的方向插入到我的在线声音文件中,我都会在 ActionScript 中遇到我无法理解的故障。

这些错误是:

1084:语法错误:在 _ 之前需要右括号。

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();
}
}

【问题讨论】:

    标签: actionscript streaming mp3


    【解决方案1】:

    语法错误正如它所说的那样,代码没有正确编写。例如,URLREquest 后不应有下划线

    var musicPiece:声音 = 新声音(新 URLRequest(“http://blog.0tutor.com/JeffWofford_Trouble.mp3”));

    在同一个地方开始应该被注释掉,仅仅因为它是一个注释,它不是一个变量或一个函数。

    调用函数“play_”也不是很好的做法。如果您担心冲突,请称之为 soundPlay。

    pause_ 和 stop_ 的注释相同

    【讨论】:

      猜你喜欢
      • 2021-09-17
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-14
      相关资源
      最近更新 更多