0
votes

Here I have AS3 to for uploading recorded sound file to server. When I test it in Flash it works properly (record sound and upload it and goes to next frame) , but in browser it doesn't work. It seems can't call myUpload but I don't why? Is it should be mouse event? Thanks.

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
}

Update:

In Flash Player 10 and Actionscript 3.0, all the calls to URLLoader must be in the same callstack. http://helpx.adobe.com/flash-player/kb/user-interaction-required-upload-download.html What is same callstack mean?

1
What leads you to believe the function isn't running? Are you running it in debug mode with break points? Or are you just guessing that is what happened? - Amy Blankenship
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. - Amirhosein Heydari
@amy . But I don't use Filereference.browse, FileReference.download or FileReference.save. Why it needs user interaction? - Amirhosein Heydari

1 Answers

0
votes

I recommend using something like Vizzy: https://code.google.com/p/flash-tracer/ to debug your swf in the browser. You can put trace statements into the onRecordComplete() and myUpload() functions, etc, to see how far the code is getting, and to see if you are getting any new errors. You may have some kind of security sandbox error because you are running in the browser. Being able to see what that error is will help you figure out what to do next.

To use Vizzy, you need to have the debug player running in your browser, and to configure the right path to your log file. This is sometimes a little bit tricky, so I'll give you some tips:

Add a file to your home directory called mm.cfg, and populate it with these settings:

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

Then in Vizzy you have to set up the path to the log. On my windows 7 machine it is here:

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

It may be different depending on your operating system.

Good luck, and report back if you Vizzy gives you any new information.