soundmanager2 and crossdomain
When all the files are on the same domain it works great but I'm trying to do something more complicated:
I have an html page on domain A that loads all the resources from domain B including the soundmanager2.js, soundmanager2.swf and test.mp3 file.
I can see that soundmanager2.swf loads but it doesn't play the test.mp3 file and I don't see it's being loaded.
Is there some cross-domain issue? Can't the javascript file talk to the swf file if they are from two different domains?
Thanks
I have an html page on domain A that loads all the resources from domain B including the soundmanager2.js, soundmanager2.swf and test.mp3 file.
I can see that soundmanager2.swf loads but it doesn't play the test.mp3 file and I don't see it's being loaded.
Is there some cross-domain issue? Can't the javascript file talk to the swf file if they are from two different domains?
Thanks
2
people have this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
The best answers from the company
-
I have added allowDomain() stubs to the SM2 source, both AS2 and AS3 (flash 9) versions. I haven't tested the method myself, but it should work according to Adobe's documentation. Keep in mind this is only for ExternalInterface as far as I'm aware, ie., it will let HTML on domain A load the SM2 .SWF on domain B, and allow for the SWF to make and receive javascript calls. For loading MP3s cross-domain, you will want to look at crossdomain.xml files which are a whole other can of worms. I also need to investigate this separately, as I'm not explicitly instructing the Flash 9 version to do cross-domain checks at this point.
Download the latest version of SM2 and see the .as files under the src/ subdirectory. You will need to recompile new .SWF movies after adding your domains, I recommend MTASC for flash 8 and Adobe's free flex SDK with mxmlc compiler for flash 9. Sample commandline scripts are also provided in that directory for reference.
Let me know if there are issues, but this should solve your cross-domain woes! :)
I’m pretty confident!
The company and 1 other person say
this answers the question
-
You've got it: Flash is pretty good about cross-domain security (though an inconvenience at times), and this includes ExternalInterface (javascript-to-flash communication), and vice-versa, by default.
In the simplest case, the Flash movie needs to load from the same domain as the hosting web page (ie., both from domain A) for JS-Flash communication to be allowed (and thus, for SM2 to work.) If your .SWF is loading from a different domain, js-to-flash communication will not work unless you make a security exception.
You can make an exception I believe by adding "allowDomain" and specifying the domains you'll be loading it from, eg. allowDomain('domain-a.com'), to the SoundManager 2 actionscript source code and recompiling the .swf.
The syntax varies slightly between versions, so you'll want to look at the language reference.
allowDomain for AS2/flash 8:
http://livedocs.adobe.com/flash/8/mai...
allowDomain for AS3/Flash 9:
http://livedocs.adobe.com/flash/9.0/A...
There is also "allowInsecureDomain", but I haven't looked into the details of it, and the name doesn't imply good things. I'll consider adding allowDomain()-related stubs to the .as source code for SM2 with the next release, for convenience.
There are also crossdomain.xml files which can grant Flash certain security permissions, but this I think is more for loading external resources from the Flash movie itself (eg. access to ID3 in MP3s on external domains), and doesn't relate to ExternalInterface
I’m confident
The company says
this answers the question
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?You've got it: Flash is pretty good about cross-domain security (though an inconvenience at times), and this includes ExternalInterface (javascript-to-flash communication), and vice-versa, by default.
In the simplest case, the Flash movie needs to load from the same domain as the hosting web page (ie., both from domain A) for JS-Flash communication to be allowed (and thus, for SM2 to work.) If your .SWF is loading from a different domain, js-to-flash communication will not work unless you make a security exception.
You can make an exception I believe by adding "allowDomain" and specifying the domains you'll be loading it from, eg. allowDomain('domain-a.com'), to the SoundManager 2 actionscript source code and recompiling the .swf.
The syntax varies slightly between versions, so you'll want to look at the language reference.
allowDomain for AS2/flash 8:
http://livedocs.adobe.com/flash/8/mai...
allowDomain for AS3/Flash 9:
http://livedocs.adobe.com/flash/9.0/A...
There is also "allowInsecureDomain", but I haven't looked into the details of it, and the name doesn't imply good things. I'll consider adding allowDomain()-related stubs to the .as source code for SM2 with the next release, for convenience.
There are also crossdomain.xml files which can grant Flash certain security permissions, but this I think is more for loading external resources from the Flash movie itself (eg. access to ID3 in MP3s on external domains), and doesn't relate to ExternalInterface
I’m confident
The company says
this answers the question
-
Inappropriate?That makes sense.
I've read that crossdomain file exposes the users to security problems and the big companies isolates the api with sub-domains.
I'll try to render the swf with your suggestion and will be grateful when you'll add a method to the next release.
Thanks -
Inappropriate?Hi,
I have exactly the same need. I need to download swf and mp3 files from a different from the one on which the web page is hosted. Next release will be very helpfull for me also. :-) Is there any scheduled date off when the next release will be...released ? :-)
Thanks
I’m thankful
-
Inappropriate?I have added allowDomain() stubs to the SM2 source, both AS2 and AS3 (flash 9) versions. I haven't tested the method myself, but it should work according to Adobe's documentation. Keep in mind this is only for ExternalInterface as far as I'm aware, ie., it will let HTML on domain A load the SM2 .SWF on domain B, and allow for the SWF to make and receive javascript calls. For loading MP3s cross-domain, you will want to look at crossdomain.xml files which are a whole other can of worms. I also need to investigate this separately, as I'm not explicitly instructing the Flash 9 version to do cross-domain checks at this point.
Download the latest version of SM2 and see the .as files under the src/ subdirectory. You will need to recompile new .SWF movies after adding your domains, I recommend MTASC for flash 8 and Adobe's free flex SDK with mxmlc compiler for flash 9. Sample commandline scripts are also provided in that directory for reference.
Let me know if there are issues, but this should solve your cross-domain woes! :)
I’m pretty confident!
The company and 1 other person say
this answers the question
-
Inappropriate?Hi again,
thank your for you quick and complete answer.
I successfully compiled .as file with MTASC. I just added following lines to .as file :
System.security.allowDomain("*");
Indeed, I need to allow the .swf file to be loaded from any domain.
Thank you again for your help and for your SoundManager2 API
I’m happy
1 person says
this answers the question
-
W00t! Good to know it works.
Loading Profile...




EMPLOYEE
