0
votes

i am working with JS and AS3 to get default mic. below is my html code

js on head

    $(document).ready(function(){
     $("#setupMic").click(function() {
      try{
       document.getElementById('test').setupMic();
      } catch(err) {
       console.log(err.message);
      } 
     });
    });
    
js after div flashContent
    var callback = function(e){ if(e.success) console.log("Loading Success"); else console.log("Loading Failed");};
    var flashvars = {};
    var params = {allowscriptaccess:"always"}; 
    var attributes = {};
    attributes.id = "test";
    swfobject.embedSWF("test.swf", "flashContent", "220", "140", "10", false, flashvars, params, attributes, callback);
    
my AS3 code is
    import flash.system.Security;
    import flash.external.ExternalInterface;
    var mic:Microphone;
    Security.allowDomain('*');
    ExternalInterface.addCallback("setupMic", setupMic);
    function setupMic():void {
     mic = Microphone.getMicrophone();
     mic.setLoopBack(true);
    }
    
the html is working perfectly in firefox. but not with my chrome or safari on friends mac. what am i missing. please help
1
is it due to some security issue. in firefox to work at first i need to add trusted location on flash player setting manager. if i change location, it wont work in firefox too. any hind ? - abduIntegral

1 Answers

0
votes

You may have a timing issue. Flash Player takes a moment to initialize ExternalInterface. If you try and access the SWF on domready, Flash Player might not have finished initializing ExternalInterface, which means your method setupMic() might not be available yet.

I recommend querying the SWF to see if it has finished loading. There's an example on LearnSWFObject.com: http://learnswfobject.com/advanced-topics/executing-javascript-when-the-swf-has-finished-loading/