Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-21-2009, 09:10 PM   #1
Livi17
Senior Member
 
Livi17's Avatar
 
Join Date: Sep 2005
Posts: 109
Default A working ExternalInterface.call sample?

Can someone create a working ExternalInterface.call example?

Just a simple alert function call, with the javascript function on the html page?

I've been searching for 2 days, and even samples that people have posted on blog tutorials are not working.

This sample does not even work:
http://livedocs.adobe.com/flash/9.0/...=00001655.html


Is it no longer supported?
Livi17 is offline   Reply With Quote
Old 08-21-2009, 10:56 PM   #2
Livi17
Senior Member
 
Livi17's Avatar
 
Join Date: Sep 2005
Posts: 109
Default

This does not work:

Within the HTML Head tags:
ActionScript Code:
<script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script>



In the fla:
ActionScript Code:
import flash.external.*; externalinterface.call("show_alert");

This should immediately trigger a javascript alert box when the page is loaded.
Livi17 is offline   Reply With Quote
Old 08-22-2009, 02:13 AM   #3
asf8
Senior Member
 
Join Date: Apr 2007
Posts: 4,772
Default

Are you doing your testing offline/online?
asf8 is offline   Reply With Quote
Old 08-22-2009, 02:26 AM   #4
Livi17
Senior Member
 
Livi17's Avatar
 
Join Date: Sep 2005
Posts: 109
Default

online
Livi17 is offline   Reply With Quote
Old 08-22-2009, 02:39 AM   #5
Livi17
Senior Member
 
Livi17's Avatar
 
Join Date: Sep 2005
Posts: 109
Default

Code:
setTimeout(function(){ExternalInterface.call("show_alert"");}, 1000);
This worked... delaying the call for a brief moment.
Livi17 is offline   Reply With Quote
Old 08-22-2009, 10:37 AM   #6
asf8
Senior Member
 
Join Date: Apr 2007
Posts: 4,772
Default

Glad you found a workaround.

Still Curious,

1.) Was this happening in all browsers?
2.) PC / OS X (or both?)
3.) What version of Flash Player?
asf8 is offline   Reply With Quote
Old 08-22-2009, 03:25 PM   #7
eggnogg
there's 8 pixels missing!
 
eggnogg's Avatar
 
Join Date: Apr 2003
Location: Portugal
Posts: 784
Default

the ExternalInterface doesn't work very well with IE because of a bug (in IE)
google 'as2 externalinterface ie bug' for more information but be advised the info is all scaterred and there's no official fix for this bug.

more so, theres many kinds of fixes according to many uses you can give the externallinterface. theres a fix to use the EI in a <form> tag, outside the form tag, in an invisible flash object, etc...

one of the fixes is that delay

another fix is to use swfobject2, but that brings up more bugs and fixes.

it's a nightmare, and it makes me want to upgrade to AS3
eggnogg is offline   Reply With Quote
Old 08-22-2009, 03:40 PM   #8
asf8
Senior Member
 
Join Date: Apr 2007
Posts: 4,772
Default

Quote:
Originally Posted by eggnogg View Post
the ExternalInterface doesn't work very well with IE because of a bug (in IE) google 'as2 externalinterface ie bug'
The same held true with FireFox, also with certain issues, not sure if the issues still remain a problem however. Fun, fun.
asf8 is offline   Reply With Quote
Old 08-23-2009, 02:48 AM   #9
Livi17
Senior Member
 
Livi17's Avatar
 
Join Date: Sep 2005
Posts: 109
Default

Quote:
Originally Posted by asf8 View Post
Glad you found a workaround.

Still Curious,

1.) Was this happening in all browsers?
2.) PC / OS X (or both?)
3.) What version of Flash Player?
The problem was happening on both PC and OS X.
IE, Firefox and Safari.

This fix worked on all.

I am using SWFObject as well.

Flash 10.0 r22


I think the issue was timing of events more than anything. I was using the ExternalInterface.Call on the first frame of the movie... so it was likely being called before the browser had loaded and gone through the entire external javascript file.
Livi17 is offline   Reply With Quote
Old 02-16-2012, 07:58 PM   #10
norman784
Registered User
 
Join Date: Apr 2011
Posts: 4
Default

Did you try to use full path? flash.external.ExternalInterface and take a look that you'r using the function name in lower case, i dont know if as2 its case sensitive, but.. cya

PD: I'm just post this because today i was having this issue in as2, yeah! people still using as2! and if someone have this issue hope this help him!
norman784 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:58 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.