0

This code works properly when published by Flash CS 5.5 as .swf (it prompts to browse where to save the file). However, when it is published to HTML, it doesn't work (doesn't prompt to browse the destination). Is it security issue or other problem?

import flash.display.Sprite;
import flash.media.Microphone;
import flash.system.SecurityDomain;
import org.bytearray.micrecorder.*;
import org.bytearray.micrecorder.events.RecordingEvent;
import org.bytearray.micrecorder.encoder.WaveEncoder;
import flash.events.Event;
import flash.net.FileReference;
import flash.utils.setTimeout;

var mic:Microphone;
var waveEncoder:WaveEncoder = new WaveEncoder();
var recorder:MicRecorder = new MicRecorder(waveEncoder);
var fileReference:FileReference = new FileReference();

mic = Microphone.getMicrophone();
mic.setSilenceLevel(0);
mic.gain = 100;
mic.setLoopBack(true);
mic.setUseEchoSuppression(true);
Security.showSettings("2");
addListeners();


function addListeners():void
{
    setTimeout(startIntroTime,3000);
    function startIntroTime():void
    {
        startRecording();
        setTimeout(stopRecording,5000);
    }
    recorder.addEventListener(Event.COMPLETE, recordComplete);
}

function startRecording():void
{
    if (mic != null)
    {
        recorder.record();
    }
}

function stopRecording():void
{
    recorder.stop();
    mic.setLoopBack(false);
}

function recordComplete(e:Event):void
{
    fileReference.save(recorder.output, "recording.wav");
}

1 Answer 1

2

Have a look at the documentation: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html#save()

It says :

In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception. This limitation does not apply to AIR content in the application sandbox.

So it is not possible and probably a security thing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.