FORUMS: list search recent posts

Javascript Access to Flash in Firefox/Chrome?

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Thomas MaCoy
Javascript Access to Flash in Firefox/Chrome?
on May 10, 2012 at 11:44:31 am

Okay, I'm sure this issue has been discussed before, but several hours of googling have gotten me no where. I'm trying to use Javascript to call an AS3 function in an embedded SWF file. I've attached my embed code as a text (apologies in advance for not posting it direct, but I tried 3 times and each time, after showing me exactly what I expected in Preview Post, when I checked the post itself I found large random chunks of code missing in the middle, and I've already been up for 20 some hours).

4114_embeddedcode.txt.zip
My HTML is middle of the road and I've barely touched Javascript before now; I was hours in and about to give up on this part of the site design when I suddenly got it working in IE, of all browsers. I understand (generally) that IE references flash files differently than Firefox and Chrome (object tags vs embedded tags) but for the life of my I can't get the JS function to work in anything but IE. The only command that works is getElementById; I've tried getElementsByName("Reels") and document.embeds.Reels; bottom line, if the browser is using the embed tag, I can't get JS to see it. I'm assuming it's an error in my SWF embed code, but I've tried 3 or 4 different versions and I get the same result. Any help would be appreciated, and please let me know any other details that might help. Thanks.



Return to posts index

Curtis Thompson
Re: Javascript Access to Flash in Firefox/Chrome?
on May 10, 2012 at 4:29:11 pm

hello...

can you post the working (or not so working, i guess) example somewhere on a site? i'm not a huge fan of downloading random zip files, but i'd like to see if i can see anything that would help...

sitruc


Return to posts index

Thomas MaCoy
Re: Javascript Access to Flash in Firefox/Chrome?
on May 10, 2012 at 10:39:56 pm

Perfectly understandable, I'm not sure why Cow decided to zip up a single text file.
In the interest of focusing in I slapped up a simple test site at
http://trmacoy.com/demo/callback.html

I've copied all the relevant code from my project (mainly the SWF embed, the JS function, and the AS3 callback) and swapped out the original SWF for a dead simple one. Two buttons stop and start a simple animation. One Java scripted button will also stop the animation by sending a callback to AS3, but again, it only works in IE. Thanks for taking a look, apologies for what I'm sure is sort of sloppy HTML.



Return to posts index


Curtis Thompson
Re: Javascript Access to Flash in Firefox/Chrome?
on May 11, 2012 at 2:28:21 am

hello...

check out this table here and try some of those - it might work...

http://www.permadi.com/tutorial/flashGetObject/

(now that i see your code, you are using document.getElementById(), and that is indeed not supported in the case of firefox and chrome, but they do have other options there)

sitruc


Return to posts index

Thomas MaCoy
Re: Javascript Access to Flash in Firefox/Chrome?
on May 11, 2012 at 5:14:52 am

Funny, that was one of the first pages I came across in my searching, and I thought I'd pretty much picked it dry. Buttt, some digging and retesting and I seem to have hit upon a solution; I had problems getting their browser detection to work, so I tried my own. Rather than writing a separate function, I just included it in the JS Callback I'm using, like so:
http://trmacoy.com/demo/callback.html
I also found some of the platforms (IE at least) react poorly if the Object ID and Embed Name are identical, which I assume is some error on my end because every other source I've viewed had them matching. But at this point, I've got a successful test on IE/FF/Chrome (PC) and FF/Chrome/Safari (OSX) and feel pretty strongly that if it's not broke, don't fix it. If you're curious and want to glance at the updated code and post back if you see anything devastatingly wrong or out of compliance I'd welcome it, but otherwise, thanks very much for the pointer.



Return to posts index

Curtis Thompson
Re: Javascript Access to Flash in Firefox/Chrome?
on May 11, 2012 at 5:19:04 am

that does seem to be working better! for some reason, testing "netscape" seems very dated and would make me nervous that such a test might fail at some point in the future, but other than that, it does seem to be good to go...


Return to posts index


Thomas MaCoy
Re: Javascript Access to Flash in Firefox/Chrome?
on May 11, 2012 at 11:04:04 am

I know, the use of Netscape is really weird, but for some reason that's what Firefox and Chrome both report back under. Probably nothing to do but keep an eye on it. Thanks again for your help!



Return to posts index

Curtis Thompson
Re: Javascript Access to Flash in Firefox/Chrome?
on May 11, 2012 at 6:30:23 pm

hello...

back in the day you were either netscape or internet explorer, and so the continued usage of netscape is sort of a default way of saying that you are of that model of compliance...

and firefox evolved out of netscape's ashes so it all makes sense...

sitruc


Return to posts index

Thomas MaCoy
Re: Javascript Access to Flash in Firefox/Chrome?
on May 13, 2012 at 7:44:30 pm

Ah, figured it was something like that. Thanks for the clarification.
-Tom



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]