Copy link to clipboard
Copied
I am trying to send a function to my SWF file via an HTML file, and every browser works fine
except for Internet Explorer.
The test file is supposed to animate the graph when you mouse over the word click, and
come to a halt upon mousing off of it.
Here is the example URL:
http://www.sirbgb.com/sotiris/final/test.html
Can someone please help me get this working on Internet Explorer? Here is my HTML code:
*** begin ***
<script type="text/javascript">
function sendToActionScript(str) {
document["accelachart"].sendToActionScript(str);
}
</script>
<a href = "#" onmouseover="sendToActionScript('fast')" onmouseout="sendToActionScript('slow')">click</a>
<object width="320" height="190" id="accelachart">
<param name="movie" value="accelachart.swf">
<param name="allowScriptAccess" value="always" />
<embed src="accelachart.swf" width="320" height="190" name="accelachart" allowScriptAccess="always">
</embed>
</object>
*** end ***
Here is my AS3 code:
*** begin ***
var acceleration:Number = 0;
var timer:Timer = new Timer(200);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(e:TimerEvent):void {
if (ExternalInterface.available) {
ExternalInterface.addCallback("sendToActionScript",fromJS);
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, onTimer);
timer = null;
}
}
function fromJS(str:String):void {
if (str == "fast")
acceleration = .5;
else
acceleration = -4;
}
*** end ***
Like I said before, it works on all browsers I tested (Chrome, FireFox, Safari) except for IE (7 or 8).
Thanks a bunch to anyone who can help with this. It has plagued me for a while.
1 Correct answer
I don't know which is line 10 but the problem may be this line:
<a href = "#" onmouseover="sendTo...
IE may be choking on the # or on calling a function from a mouse over event.
You might want to add an alert call to the JS to see if either function is being called. You might also turn on script debugging in IE. You can do that from Tools...Internet Options... Advanced...Disable Script Debugging, this may give you better information to work with.
Copy link to clipboard
Copied
For IE you need to use window["accelachart"].sendToActionScript(str); So, to do this right, you'll need to parse out the browser before you issue the command. Look at the ExternalInterface example code in the online help for an example of how to do this.
Copy link to clipboard
Copied
Ok, I found an example and have modified my HTML code to the following (Bold is what I added/changed):
<script type="text/javascript">
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
function sendToActionScript(str) {
thisMovie("accelachart").sendToActionScript(value);
}
<a href = "#" onmouseover="sendToActionScript('fast')" onmouseout="sendToActionScript('slow')">click</a>
<object width="320" height="190" id="accelachart">
<param name="movie" value="accelachart.swf">
<param name="allowScriptAccess" value="always" />
<embed src="accelachart.swf" width="320" height="190" name="accelachart" allowScriptAccess="always">
</embed>
</object>
Unfortunately, nothing seems to have changed. It still works in all of the browsers except IE. My specific error code is:
Line: 10, Char: 4, Error: Object doesn't support this property or method, Code: 0, URL: my url
I tried looking at other ExternalInterface examples, but they all said pretty much the same thing. Any advice?
Copy link to clipboard
Copied
I don't know which is line 10 but the problem may be this line:
<a href = "#" onmouseover="sendTo...
IE may be choking on the # or on calling a function from a mouse over event.
You might want to add an alert call to the JS to see if either function is being called. You might also turn on script debugging in IE. You can do that from Tools...Internet Options... Advanced...Disable Script Debugging, this may give you better information to work with.
Copy link to clipboard
Copied
I made a mistake, the line was 19. The actual line 19 in my code is:
thisMovie("accelachart").sendToActionScript(str);
I also changed the href="#" to href="test.html" which is the name of
my HTML file.
I put an alert in both functions, and they are being called, and the variables
look correct as well.
I turned on script debugging as well, and it reported a runtime error on line
52. Unfortunately my HTML file only has 33 lines, so I am confused. The
error is "Object Required" It will also complain bout both my alert and the
the thisMovie line (if I delete the alert) in the following code:
function sendToActionScript(str) {
alert('In sendActionScript function, value is ' + str);
thisMovie("accelachart").sendToActionScript(str);
}
The debug report is the same for this error and the line 52 one:
Unhandled Exception ('Object doesn't support this property or method')
occured in iexplore.exe [3988]. Just-In-Time debugging this exception
failed with the following error: No installed debugger has Just-In-Time
debugging enabled. In Visual Studio, Just-In-Time debugging can be
enabled from Tools/Options/Debugging/Just-In-Time
I have Visual C# and C++ 2008, but I do not know where to find the
Visual Studios program they are talking about.
Thank you for the help so far. Do you have any other ideas on how I
can get this working?
Copy link to clipboard
Copied
I don't know what the problem might be. I wouldn't worry about any reference to visual studio. You are testing this from a server, right? I found this article, http://www.rooftopsolutions.nl/article/245, see if there's anything in there that might point to your problem.
Copy link to clipboard
Copied
Yes, I am testing this from my webserver. You can find it at the URL at the beginning of this question
if you want to take a look. I did make some progress.
I appreciate the link, it has some really good tips on the subject. And I have followed everything there,
to my knowledge. My <object> tag has an id, it doesn't overlap the document object keywords, it is not
in a <form> tag, I didn't use play or stop, and I added Security.allowDomain('*') to my AS3 code.
Unfortunately, none of these worked. But, the Microsoft script debugger they linked me to has shed a
LOT more light on the subject. For example, I finally figured out what the errors are.
The following is the "Line 52" error that occurs when the page loads or is refreshed (Green Text = Problem)
function __flash__removeCallback(instance, name) {
}
I'm not sure what to make of this, do you have any ideas? Not sure if it is located in something with my
HTML and Javascript, or if it is in the AS3 code.
The other error in my HTML occured on rollover and rollout, and it is:
Copy link to clipboard
Copied
Hey, thanks to you I was able to find a solution! Apparently the <embed> tag was causing all of the trouble. I changed my SWF <object> information to the following:
<object type="application/x-shockwave-flash" width="320" height="190" data="accelachart.swf" id="myChart">
<param name="movie" value="accelachart.swf" />
<param name="quality" value="high" />
<param name="allowScriptAccess" value="always" />
</object>
And it now works in all browsers, including IE!
Thanks again, that problem was bothering me for a while.

