Firefox, SWFObject and ActionScript 3.0 Wrapper for Chromeless Player meltdown

19 views
Skip to first unread message

virtualight

unread,
Nov 17, 2009, 2:36:25 PM11/17/09
to SWFObject
Firefox, SWFObject and ActionScript 3.0 Wrapper for Chromeless Player
meltdown

I know a lot of postings have mentioned problems with Firefox and
SWFObject and the "Error calling method on NPObject! [plugin
exception: Error in Actionscript. Use a try/catch block to find
error]" message, but I'm adding YouTube videos into the mix as well.

The situation: I've created a website -- http://www.cuculcan.com/ --
that works quite well in Safari and Internet Explorer. I use SWFObject
2.2 to static publish the Flash and I'm using this solution --
http://code.google.com/apis/youtube/articles/youtube_as3_chromeless.html
-- to play YouTube videos. It uses the ExternalInterface.addCallback
method to communicate with the YouTube api.

But Firefox 3.5 won't play the videos unless I switch to dynamic
publishing. Here's an example of the videos playing in Firefox --
http://www.cuculcan.com/viewer.html. Unfortunately, you'll have to
manually search for the Race to the Moon timeline to find a timeline
with a YouTube video in it.

Dynamic publishing, however, causes a problem that affects not just
Firefox. The main Flash movie loads another swf that contains the drag
bar that divides and resizes the Flash content vs the html content.
Both the loader, main viewer and drag bar swfs are all on the root
level of the same domain and all are loaded using the same full path.
However, when using dynamic publishing, I get the "Error calling
method on NPObject!" in both Safari and Firefox, and I've tracked this
down to an ExternalInterface.addCallback that exposes a Flash function
to JavaScript.

That Flash function simply repositions the drag bar swf vertically,
which happens without a hitch under static publishing, but under
dynamic generates a #1009 error. I assume that because of the bait and
switch nature of dynamic publishing, the drag bar hasn't loaded yet.
I'm calling the Flash function (via JavaScript) in the onload handler
for the window, but I'm guessing that's no longer working. And I can't
create an onload handler for a div.

My ultimate solution would be to switch to dynamic publishing and move
the drag bar back into the main swf as a sprite and not a loaded
movie. It's only a 2K swf and would remove any suspicion that's what's
happening is a security issue (my first thought until I confirmed that
everything is referenced by the same domain name) and remove the #1009
error.

My preferred solution would be to find a way to get static publishing,
Firefox and the YouTube video solution to work, so if anyone has a
suggestion how to do that, I'd appreciate it.

Thanks,

Jennifer

PS What is interesting is that this demo of the ActionScript 3.0
Wrapper for Chromeless Player --
http://youtubechromelesswrapper-as3.googlecode.com/svn/trunk/as3wrapper/deploy/index.html
-- uses dynamic publishing, leading me to believe that dynamic
publishing is the only way to go.

virtualight

unread,
Nov 17, 2009, 4:59:40 PM11/17/09
to SWFObject
Boy, I thought I had the answer when I found swfobject.addDomLoadEvent
(functionName)

This calls functionName when the dom of the page is available, which I
thought would be after SWFObject has swapped out the DIV for the
Flash. I had been calling my Flash function during window.onload, but
addDomLoadEvent still doesn't work. I think now I'll just cheat and
throw in a setTimeout and see if the loading delay is really the
culprit or if it's a security issue.

Jennifer

Aran Rhee

unread,
Nov 17, 2009, 6:17:02 PM11/17/09
to swfo...@googlegroups.com
Hi Jennifer.

addDomLoadEvent() is not fired after the swf is embedded, but when the DOM is available (ie you can get to all of the elements on your page). You can use this function to delay the embedding of your Flash file or run some other function after the page elements are available. SWFObject inteternally uses the domReady event to init all of its own proceses.

Perhaps you want to look at the callback function (the last param on both the static and dynamic publishing methods) if you need to ensure the swf has been written to the page before calling something else.

There are some people on this list who have intimate knowledge of the Youtube API, so I am hopeful they can sort out your issue.


Cheers,
Aran


--

You received this message because you are subscribed to the Google Groups "SWFObject" group.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=.



Jennifer Petkus

unread,
Nov 17, 2009, 6:24:02 PM11/17/09
to swfo...@googlegroups.com
Thanks, Aran. I see what you mean about addDomLoadEvent. Further
investigation makes it clear to me that when using dynamic publishing,
my drag bar swf is not loading at all. It seems that the Loader.load()
is not being fired at all, so I'm not getting an error AND it's why
I'm getting the #1009 error.

Adding a timeout did get around the div not found error and I'll
implement a more elegant solution later.

Jennifer

virtualight

unread,
Nov 17, 2009, 6:32:44 PM11/17/09
to SWFObject
It looks like I'm suffering from a comedy of errors. I confirmed that
my drag bar component was not loading, which seems to have been a
consequence of my flashvars being ignored (I must have a typo
somewhere). Because one of the stage.loaderInfo.parameters was
missing, the if () statement prevented a call to load the drag bar.
Because the load was never called, the subsequent call from JavaScript
generated the #1009 error, further obfuscated by the
"document.getElementById("viewerMovie").resetDragBarJS(flashheight) is
not a function" error caused by the extra delay inherent in the
dynamic publishing method.

So I have to figure out why my flashvar is missing, and I think most
of problems are solved (well, for today anyway).

Jennifer

virtualight

unread,
Nov 17, 2009, 7:12:10 PM11/17/09
to SWFObject
IT WAS A TYPO! The difference between flashvars.loadobject = "?ti,e1"
and flashvars.loadobjects = "?ti,e1". A lousy letter "s". Two misspent
days. Argh! D'oh! Baka tari!

I apologize for wasting everyones time but thank you for listening.

Jennifer

PS So now http://www.cuculcan.com/ works for Firefox without any
errors, but definitely dynamic publishing is necessary to get those
YouTube videos to play.

Aran Rhee

unread,
Nov 17, 2009, 7:25:23 PM11/17/09
to swfo...@googlegroups.com
I am glad that you got it working (even if you did lose some hair over the last few days!). Japanese swear words always work for me too :)

BTW - As a general rule of thumb, if there is any other js interaction happening with the page, it is a good idea to use dynamic publishing. You have much more control over how and when your swf is created etc.


Cheers,
Aran




Reply all
Reply to author
Forward
0 new messages