View Full Version : Script communicating with flash runs only once on IE
3pepe3
11-14-2008, 09:06 AM
Hello world,
And sorry for being to many days out of the community, but the last months i didn't have time for being here... Well no I have a problem on IE.
I have X number of thumbs on one side (html), each thumb can be pressed and this is going to send a request for a flash app...
This is working on firefox, but on IE it runs fine just one time and the next time I get an error that saids something like this:
"This object doesn't have this property or method"
<script type="text/javascript">
function getFlashMovie(movieName) {
//Adobe method for the use of ExternalInterface...
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var obj=(isIE) ? window[movieName] : document[movieName];
/*
for me this would do the same trick:
var obj=document.getElementById(movieName);
*/
return obj;
}
function sendToFlash(num) {
var obj=getFlashMovie("mon_swf_app");
///sendTextToFlash is a function of the flash application...
/*
The debbuer tells me that the problem is on the next line,
but why it is working one time and the next time it's not working on IE?
*/
obj.sendTextToFlash(num);
return true;
}
</script>
you can test and see the problem here:
link removed
Any input, advice or help will be great.
thanks
Pepe
3pepe3
11-14-2008, 10:46 AM
this is so weird....
http://www.gotoandlearnforum.com/viewtopic.php?f=29&t=13969
I thought that this thread was the answer to the problem, but there was no luck.
The problem is that you can click on the thumbs and all is ok... you press the tv on the middle of the screen an a litebox is opened... then if you try to click again on the thumb there is a problem...
the function of flash is not longer a function... it becomes an object.
This means that when i'm debugging the javascript i test the "typeof obj.sendTextToFlash"
the first time that i test (and i works) the value of typeof obj.sendTextToFlash is "function"
and the second time i test this i get "object"
the AS is:
ExternalInterface.addCallback("sendTextToFlash", _root, getTextFromJavaScript);
and the code on the html (js) looks like this:
function sendToFlash(num) {
var obj=getFlashMovie("mon_swf_app");
debugger;
obj.sendTextToFlash(num);
return true;
}
So the question is:
Why obj.sendTextToFlash (function) becomes an object?
3pepe3
11-14-2008, 09:42 PM
:mad::mad::mad:
GRRRRRRRRRRRRR.......
Well now i know that the js and the externalinterface was ok...
Reading this other thread (http://www.actionscript.org/forums/showthread.php3?t=134728), i got a new idea and the problem was not the flash communication with js... the problem is the lightbox that it's opened.
This lightbox seems to disable temporally the display of the SWF (this means that the movie becomes invisible while the lightbox is opened); then the lightbox is closed and the SWF becomes again visible... For firefox (and for me) this feature is normal and it's for preserve the user resources (CPU)... but for IE there is a bug and when the movie is set again to visible then the SWF is not longer the same (it's break).
I discovered the culprit on this function:
function openFlashRequest(str) {
var el=document.getElementById('btn_'+str)
alert("mediabox must be opened");
/*if Mediabox is executed then the js will throw the error*/
//Mediabox.open("/realisations/index.php?id="+str,el.alt,'mediabox[700 360]');
}
Now the question becomes how to fix/hack this IE bug or modify the lightbox core!!
the lightbox is very nice but will break the SWFs that use the addCallback method.
http://iaian7.com/webcode/mediaboxAdvanced
or the problem will be caused by mootools (used on the mediabox)????
gggggrrrrrr
to many question and analysis to do
Any help input will be great...
:)
3pepe3
11-17-2008, 01:02 PM
This is so weird...
On the javascript I change a little the function so now if the function becomes an object i saved the function into another variable named "f"... now when the function obj.sendTextToFlash is an "object" then the f is detected as a function ("typeof f" is "function")
but then i get an script error on another function that i think that it's part of the swfobject 2.1
The current function:
function sendToFlash(num) {
var obj=swfobject.getObjectById('monswfapp');
if(typeof obj.sendTextToFlash=="object"){
f(num);
}else{
obj.sendTextToFlash(num)
f=obj.sendTextToFlash
}
}
and the new error appears on:
obj[functionName] = function(){return eval(this.CallFunction("<invoke name=\"sendTextToFlash\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments,0) + "</invoke>"));}
AHHHH.... this is insane
:s
3pepe3
11-17-2008, 01:11 PM
Well a dirty shot that I think that "solves" the puzzle....
var eiEnabled:Boolean = ExternalInterface.addCallback("sendTextToFlash", _root, getTextFromJavaScript);
function rebuildExtIntFunc()
{
eiEnabled = ExternalInterface.addCallback("sendTextToFlash", _root, getTextFromJavaScript);
}
id_extInt = setInterval(rebuildExtIntFunc, 100);
anndr0id
08-31-2009, 11:16 PM
I'm having the same exact issue you've had here using ShadowBox. I'm using Actionscript 3 though. Did you ever find a solution that worked for you with this?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.