Skip to main content
November 6, 2007
Answered

Problem with AS3 "ExternalInterface.call" in InternetExplorer

  • November 6, 2007
  • 2 replies
  • 488 views
Hi,

Explaining how the page is setup:

I have a HTML page with 2 different AS3 Flash movies.

The first flash movie is the main animation and sits in the middle of the screen with a large background image set into the body of the HTML.

The second flash movie stretches 100% width/height of the screen dimensions and acts as a fade from black>to invisible.

What I'm trying to do:

Once the second Flash animation has faded from black to invisible it calls a JavaScript function in the HTML page to hide the div element the second flash movie is embed into (this is because the first flash movie will display a set of input boxes which the user needs to be able to type into - which they wont be able to click on if there is another flash movie overlaying the entire first movie).

My intial solution:

In the second Flash movie is the following code:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
stop();

// this will load the API necessary to communicate with external entities
import flash.external.ExternalInterface;

// call the JavaScript function
ExternalInterface.call('myJavaScriptFunction');
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

...and this works fine in Mozilla Firefox/Safari. The actionscript successfully calls the JavaScript function in the HTML page and that JavaScript function simply (at this stage displays an alert() message to show that it has been successfully called).

Problem with IE:

But, the moment I try this in Internet Explorer I don't get a alert() message but a JavaScript error message that says:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Code: Select all
Line: 1
Char: 106
Error: 'null' is null or not an object
Code: 0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

As you can expect I'm totally confused as to what the problem could be.

This is really urgent as it's a live project that needs to get completed immediately, so any help you may have would be greatly appreciated!

Kind regards,

Mark.
This topic has been closed for replies.
Correct answer
Hi GWD,

That did it !! :)

I applied the attribute id="fTrans" to the <object> tag and IE worked fine.

I was bashing my brains out over that one, thank you so much!

Kind regards,
Mark

2 replies

Inspiring
November 7, 2007
You're welcome.
Inspiring
November 6, 2007
My guess is that its to do with your embedding code. Check a) you have an id attribute assigned to the resulting object tag from whatever embedding method you use and b) for good measure make sure its unique in your html page.

Javascript needs to have a valid reference to return the value from the javascript function back to flash. In my experience IE is more sensitive to issues here.

If you get stuck post a test page somewhere.

Tools to use to help with javascript debugging and view the html embed results (e.g. from swfobject or activecontent.js):

In firefox : Firebug
In IE: IE Developer Toolbar , Companion JS, and DebugBar are all helpful and , combined, get close to Firebug.
November 7, 2007
Hi GWD,

That did it !! :)

I applied the attribute id="fTrans" to the <object> tag and IE worked fine.

I was bashing my brains out over that one, thank you so much!

Kind regards,
Mark