Question

I try make simple ExternalInterface mechanism for flash-facebook login with js sdk but the callback to flash isn't run because the GetElementById("flashContent") is null >>> Console said.

How I should fix it? I've try it in Firefox, etc and give same result. When I click the button, it call the checklogin js but when the process complete and try call back flash, the methode GetElementById(...).onLogin not runs.

The code:

function requestLogin() {                
            FB.login(function(response) {
                if (response.authResponse) {
                    console.log('Welcome!  Fetching your information.... ');
                    FB.api('/me', function(response) {
                    console.log('Good to see you, ' + response.name + '.');
                });
                    document.getElementById('dua').onLogin();                        
                } else {
                    console.log('User cancelled login or did not fully authorize.');
                     document.getElementById('dua').onError();
                }
            });
        }
    </script>
    <div id="flashContent">
        <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="dua" align="middle">
            <param name="movie" value="dua.swf" />
            <param name="quality" value="high" />
            <param name="bgcolor" value="#ffffff" />
            <param name="play" value="true" />
            <param name="loop" value="true" />
            <param name="wmode" value="transparent" />
            <param name="scale" value="showall" />
            <param name="menu" value="true" />
            <param name="devicefont" value="false" />
            <param name="salign" value="" />
            <param name="allowScriptAccess" value="always" />
            <!--[if !IE]>-->
            <object id="dua" type="application/x-shockwave-flash" data="dua.swf" width="550" height="400">
                <param name="movie" value="dua.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="transparent" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="always" />
                <!--<![endif]-->
                <a href="http://www.adobe.com/go/getflash">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                </a>
                <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
        </object>
    </div>

AS3 code:

import flash.events.DataEvent;
import flash.events.MouseEvent;
flash.system.Security.allowDomain("*");
flash.system.Security.allowInsecureDomain("*");

tombol.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void{
FBconnect();
tombol.removeEventListener(MouseEvent.CLICK, onClick);
}
function FBconnect():void {
    teks.text = "masuk fbconnect";            
        ExternalInterface.call("requestLogin");
    ExternalInterface.addCallback("onLogin", onLogin);
        ExternalInterface.addCallback("onError", onError);
 }

function onError():void {
 teks.text = "onError";
     trace('error');
 }

function logout():void {
      ExternalInterface.call("FB.logout", null);
}

function onLogin():void {
 teks.text = "onlogin";
     trace("FB LOGIN");
     connectUser();
 }

 function connectUser():void {
     teks.text = "connectUser";
     ExternalInterface.addCallback("loadUser", userCallback);
     ExternalInterface.call("connectUser");
   }

 function userCallback(data:Array):void {
  teks.text = "user callback";
      trace("FB USER LOADED");
      var userData:Object = data[0];
  }
Was it helpful?

Solution

I've found solution around this problem. First the, when I try set id getelementbyid with flashContent it didn't run well. But when I try with id="dua" it didn't run weel too. So, I check it with inspect the element, and I found that the object was being displayed is the second one which doesnot contain id. So, I give an id and call it in getelementbyid. So, when I try test it in any browser, it run well but when I try to test it in IE, I must set the getelementbyid with IE methode provide.

-CMIIW-

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top