【问题标题】:AS3: Call function does not work in browserAS3:调用功能在浏览器中不起作用
【发布时间】:2013-10-16 20:30:40
【问题描述】:

这里我有 AS3 用于将录制的声音文件上传到服务器。当我在 Flash 中测试它时,它可以正常工作(录制声音并上传并转到下一帧),但在浏览器中它不起作用。似乎无法调用 myUpload 但我不知道为什么?应该是鼠标事件吗?谢谢。

function VOCWordToYourMp3()
{
    setTimeout(startRecording,3000);
    recorder.addEventListener(RecordingEvent.RECORDING, onRecording);
    recorder.addEventListener(Event.COMPLETE, onRecordComplete);
}

function startRecording()
{
    if (! recording)
    {
        recorder.record();
    }
    else if (recording)
    {
        recorder.stop();
        recording = false;
    }
}
function onRecording(e:RecordingEvent)
{
    //
}

function onRecordComplete(e:Event):void
{
  //
}
function renderWav(src, convertToMp3 = false)
{
            //
    function handleRenderTimer(e:TimerEvent)
    {
        //
    }
    function finishRender()
    {
           //  
    }
}
function makeIntoMp3(wav)
{
    wav.position = 0;
    mp3Encoder = new ShineMP3Encoder(wav);
    mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);
    mp3Encoder.addEventListener(ProgressEvent.PROGRESS, mp3EncodeProgress);
    mp3Encoder.start();

    function mp3EncodeProgress(e:ProgressEvent):void
    {
        //
    }

    function mp3EncodeComplete(e: Event):void
    {
        myUpload('sound1',mp3Encoder.mp3Data);
    }
}

function myUpload(namefile:String,sba: ByteArray):void
{
//upload code
}

更新:

在 Flash Player 10 和 Actionscript 3.0 中,对 URLLoader 的所有调用都必须在同一个调用堆栈中。 http://helpx.adobe.com/flash-player/kb/user-interaction-required-upload-download.html 同一个调用栈是什么意思?

【问题讨论】:

  • 是什么让您相信该功能没有运行?您是否在带有断点的调试模式下运行它?还是您只是猜测发生了什么?
  • SecurityError: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
  • @amy 。但我不使用Filereference.browse, FileReference.downloadFileReference.save。为什么需要用户交互?

标签: actionscript-3


【解决方案1】:

我建议使用类似 Vizzy:https://code.google.com/p/flash-tracer/ 在浏览器中调试您的 swf。您可以将跟踪语句放入onRecordComplete()myUpload() 等函数中,以查看代码的执行情况,并查看是否出现任何新错误。由于您在浏览器中运行,您可能会遇到某种安全沙箱错误。能够看到该错误是什么将帮助您弄清楚下一步该做什么。

要使用 Vizzy,您需要在浏览器中运行调试播放器,并配置正确的日志文件路径。这有时有点棘手,所以我会给你一些提示:

将一个名为 mm.cfg 的文件添加到您的主目录,并使用以下设置填充它:

ErrorReportingEnable=1
AS3Verbose=0
TraceOutputFileEnable=1
AS3Trace=0
TraceOutputBuffered=0
AS3StaticProfile=0

然后在 Vizzy 中,您必须设置日志的路径。在我的 Windows 7 机器上,它在这里:

C:\Users\MyUserName\AppData\Roaming\Macromedia\Flash Player\Logs\flashlog.txt

根据您的操作系统可能会有所不同。

祝你好运,如果 Vizzy 向你提供任何新信息,请及时报告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 2018-01-27
    相关资源
    最近更新 更多