MySpace Developer Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

registering AS function with JS problem

Last post 06-28-2008 4:14 PM by Gianluca. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-25-2008 1:44 PM

    • v2gDev
    • Not Ranked
    • Joined on 04-10-2008
    • Posts 2

    registering AS function with JS problem

    Hi,

    I'm writing an app in Flex and I'm trying to register a function in the AS code so it can be called from the enveloping JS.

    The AS3 code looks like this:

                    ExternalInterface.addCallback("functionname", functionname);

    If the .swf were called "myspaceApp," for example, then I should be able to call myspaceApp.functioname() from the javascript, but I get the following error on attempts to load the app:

     SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller test.swf cannot access http://api.msappspace.com/apprendering/renderapp.ashx?opensocial_token=mAa9IwDossX0rZYtutVeHtOwVDghgmxeKjPWgINq1N%2bArnbl8YutjP27q6vhA9WtcvGPj9yny4j84%2b05wZrPOb%2bFkJCT9jNV50aEcZ5uArA%3d&opensocial_surface=profile.

     

    Any ideas? 

     

  • 04-26-2008 9:37 AM In reply to

    • Ben
    • Top 200 Contributor
    • Joined on 04-18-2008
    • Posts 16

    Re: registering AS function with JS problem

     When you embed your swf, set 'allowScriptAccess=always'. This lets your swf call javascript on the page.

    Also, inside your swf, you might want to call flash.system.Security.allowDomain('*'). This will allow javascript to call actionscript in the swf

  • 04-28-2008 12:09 PM In reply to

    • v2gDev
    • Not Ranked
    • Joined on 04-10-2008
    • Posts 2

    Re: registering AS function with JS problem

    Hey thanks for the reply, that fixed it.  I was experiencing cross-browser problems as well, but the following lines fixed that as well, for anybody who's interested:

    function getFlashMovie(movieName) {
      var isIE = navigator.appName.indexOf("Microsoft") != -1;
      return (isIE) ? window[movieName] : document[movieName];
     }
     
    function fn(){
       getFlashMovie("swfname").fnName();

    }

  • 06-28-2008 4:14 PM In reply to

    Re: registering AS function with JS problem

    work in IE?

Page 1 of 1 (4 items)