Forum GameFS Crossdomain or ExternalInterface error?

Discussion and help relating to the PlayerIO game asset hosting and CDN solution, GameFS.

Crossdomain or ExternalInterface error?

Postby cjcenizal » April 4th, 2011, 7:49 am

I'm using JQuery to track mouse position on the page, and passing this information to a SWF via ExternalInterface:

Code: Select all
<script type="text/javascript">
   jQuery(document).ready(function(){
      $(document).mousemove(function(e){
         var swf = swfobject.getObjectById( "game" );
         if ( swf != null && swf.setBrowserMousePosition != null ) {
            swf.setBrowserMousePosition( e.pageX, e.pageY );
         }
         });
   })
</script>
   
{% swf src='AA2.swf' width=760 height=635 id='game' rootUrl= %}


This works fine when I am testing on my own personal server, viewing the page at its original URL. But when I upload to GameFS and try to view on Facebook, Firebug shows this error:

uncaught exception: Error in Actionscript. Use a try/catch block to find error.

Google turned up some similar problems, a few of which seemed to be caused by some sort of crossdomain or security problem. Does this ring a bell with anyone? Any idea how GameFS could be interfering with ExternalInterface?
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Crossdomain or ExternalInterface error?

Postby cjcenizal » April 4th, 2011, 6:41 pm

If the PlayerIO CDN causes the SWF to be loaded from a different domain than that of the index.html file, then I figured there might be a cross-domain problem? So I tried loading a crossdomain.xml policy file into my SWF, with this code:

Code: Select all
var url:String = PlayerIO.gameFS( PLAYERIO_GAME_ID ).getURL( "/gameFolder/crossdomain.xml" );
Security.loadPolicyFile( url) );


This didn't solve the problem when deployed on the server, though when I run locally, I do get this error:

Error: Ignoring policy file requested from http://r.playerio.com/r/PLAYERIO_GAME_I ... domain.xml because a cross-domain redirect to http://cdn.playerio.com/PLAYERIO_GAME_I ... in._v4.xml occurred

So it looks like we can't load a policy file if the CDN redirects us to a new one. So I tried loading the policy file from the CDN directly:

Code: Select all
Security.loadPolicyFile( "http://cdn.playerio.com/PLAYERIO_GAME_ID/gameFolder/crossdomain.xml" );


This resulted in the following error when I ran locally:

Warning: Ignoring 'secure' attribute in policy file from http://cdn.playerio.com/crossdomain.xml. The 'secure' attribute is only permitted in HTTPS and socket policy files. See http://www.adobe.com/go/strict_policy_files for details.

Warning: Domain cdn.playerio.com does not specify a meta-policy. Applying default meta-policy 'master-only'. This configuration is deprecated. See http://www.adobe.com/go/strict_policy_files to fix this problem.

Error: Ignoring policy file at http://cdn.playerio.com/PLAYERIO_GAME_I ... domain.xml due to meta-policy 'master-only'.


This means there is a PlayerIO CDN crossdomain.xml policy file, right? Is it up-to-date as outlined in http://www.adobe.com/go/strict_policy_files? I'm still really confused about what could be causing the original errors and preventing me from passing data to my SWF via ExternalInterface. I chased the rabbit down some holes and ended up here somehow. :D
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Crossdomain or ExternalInterface error?

Postby Benjaminsen » April 4th, 2011, 6:44 pm

Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Crossdomain or ExternalInterface error?

Postby cjcenizal » April 4th, 2011, 8:01 pm

Hi, Benjaminsen! Thanks for the suggestion. It was my understanding that PlayerIO's crossdomain.xml was being loaded, and was resulting in those errors. I just tried your suggestion, loading that crossdomain directly in AS3:

Code: Select all
Security.loadPolicyFile( "http://cdn.playerio.com/crossdomain.xml" );


I get the same two warnings I mentioned earlier, and JavaScript still can't get through to the swf through ExternalInterface.
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Crossdomain or ExternalInterface error?

Postby Benjaminsen » April 5th, 2011, 5:24 pm

Did you try to set allowScriptAccess="sameDomain" or allowScriptAccess="always" on your flash embed tag?
allowScriptAccess Info

Likewise did you try to set Security.allowDomain(*) in as3? http://livedocs.adobe.com/flash/9.0/Act ... urity.html

Lastly can you post the url to me in a private message or here in the forum so I can see the error directly?
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Crossdomain or ExternalInterface error?

Postby cjcenizal » April 5th, 2011, 6:15 pm

Thank you so much for your help, Benjaminsen. Implementing both of those solved the problem. I think I initially forgot to set AllowScriptAccess='always' in my embed tag. Thanks again!
cjcenizal
Paid Member
 
Posts: 115
Joined: March 29th, 2011, 12:31 am

Re: Crossdomain or ExternalInterface error?

Postby Benjaminsen » April 5th, 2011, 11:38 pm

cjcenizal wrote:Thank you so much for your help, Benjaminsen. Implementing both of those solved the problem. I think I initially forgot to set AllowScriptAccess='always' in my embed tag. Thanks again!


My pleasure
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to GameFS



cron