Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / July 2008



Tip: Looking for answers? Try searching our database.

ExternalInterface.call across domains?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
macdeke - 24 Jul 2008 15:41 GMT
I'm using ExternalInterface.call in a swf file to call a javascript in the html
container. The swf file is located in a different domain than the html
container. Everything works fine if all files are within the same root
directory, but as soon as I reference the swf file located in the other domain,
the call stops working! What am I missing?

swf file has this in frame 1:
import flash.external.ExternalInterface;
function clickListener(eventObj:Object):Void {       
    ExternalInterface.call("sendToResponseForm");   
}

swf file has this on mc instance tracked as button:
on(press){
    clickListener();
}

html file/container has this in <head> tag:
<script type="text/javascript">
        function sendToResponseForm(){           
            window.location = "my.other.html.file";
        }
</script>

html file has this embedded:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve
rsion=6,0,29,0" width="700" height="550">   
    <param name="movie" value="http://www.otherdomain.com/vid/my.SWFFile.swf" />
        <param name="quality" value="high" />    
       <embed src="http://www.otherdomain.com/vid/my.SWFFile.swf"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="700" height="550"></embed>
</object>

Hopefully, that's enough for you to chew on. Like I said if swf and html are
in the same domain, it works. Just as soon as I point to second domain for swf
file source it stops working.

thanks
deke
macdeke - 29 Jul 2008 14:47 GMT
Anybody have any ideas?
macdeke - 31 Jul 2008 16:44 GMT
Here's my mistake -- the swf file was fine and actually worked in IE6/IE7 but
wouldn't work in Firefox. The process of including the swf file in the HTML was
flawed. I originally published the HTML using Dreamweaver to write the <object>
in the code. What fixed the problem was I published the swf file using Flash to
a desktop folder which produced a javascript file (AC_RunActiveContent.js), the
swf file and the HTML. The javascript dynamically determines which browser was
being used and which player plugin was required. The script ultimately
loads/writes the embed or object for the swf file appropriately for the content
environment and everything communicates properly. It didn't have anything to do
with cross domain communication at all.

The main challenge was updating the Flash HTML/Javascript to use the proper
swf resource which was located on a different server and move the js file to
the appropriate directory updating the link in the HTML accordingly. My only
concern was the added overhead of an external javascript source. But, at least
I'm not concerned with whether it works or not anymore.

Hope this helps somebody.

deke
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.