Workaround for SWF inside a FORM element

Had an issue with a Flash SWF inside a <FORM> element when using ExternalInterface(). Essentially flash was unable to create the callbacks and threw errors.

Thankfully there is a workaround available by Steve Kamerman 

“Wow, seriously IE – you got beat by Opera Beta. It also failed in IE7. To make a long story short, I spent 6+ hours trying to figure out what was wrong – finally I realized the code was fine and it was a IE bug. There’s a bunch of speculation and suggested fixes on the Adobe / Macromedia Flash 8 ExternalInterface() LiveDocs page, but they’re either overly-complicated or they don’t work. So I sat down and figured it out, then I made my own fix, which I consider to be very easy :D.

Here’s the solution: SWFFormFix by me, Steve Kamerman 😀. Here’s the deal, basically, you need to trick Internet Explorer because if you put an object in a form, IE’s implementation of Javascript seems to want to look for “window.yourObject” and not “document.form[x].yourObject”, so my script figures out which form you are in and makes an alias at the wrong location that points to the right location. Don’t believe me? Try it out. “

http://www.teratechnologies.net/stevekamerman/index.php?m=12&y=06&entry=entry061230-004100

 

The solution implements the following

window.yourMovieName = document.getElementById('yourMovieName');

This adds a window-level pointer to the movie so that it can be referenced directly using just the name.

Steve Kamerman is also the developer of Tera-WURFL – if you develop content for mobile devices you should be aware of the WURFL project . I’ve been compiling a database of phone specs for the last 7 years and I’m throwing it all away in favor of the WURFL XML database.

 

 

About James McParlane

CTO Massive Interactive. Ex Computer Whiz Kid - Now Grumpy Old Guru.
This entry was posted in Flash. Bookmark the permalink.

3 Responses to Workaround for SWF inside a FORM element

  1. Hi James. Long time no see!

    Rob passed this onto me because I was pulling my hair out a couple of weeks ago over this.

    I tried this solution by using his javascript and couldn’t get it to work properly. I did have some success getting the object to embed, but after that could not pass parameters to it. I THINK this solution only works properly in IE if you are prepared to turn the IE cache off in javascript (which I wasn’t prepared to do with the size of our flash file).

    Granted that was on a late night and was very frustrated, so I might be wrong, but I’ll do a little more testing after this site is fully completed and I have the time.

    ALTERTNATIVE SOLUTION (NOT PRACTICAL IN ALL CASES):
    One option is using css layers and positioning so you can put the div outside the form and dynamically create the javascript from .NET inside the form to load the swfs.

    Problem I had with this was that I needed to have a swf that was off-center in a centered site and using a centered div, then a nested one with right padding meant you couldn’t click the form fields behind it in firefox!!!
    Solution was to put the part of the .NET page at the bottom of the page inside the form and using css positioning to move it to the top on a +z-index (like the login on http://www.schickshavelab.com.au).

  2. I tried this solution and it solved the problem for me.
    If you need any assistance, email me a URL and I’ll have a look.

  3. Hi guys – I stumbled on this site today and noticed that you were talking about me :P. Stuart – I have also noticed that IE’s caching system will sometimes prevent bidirectional JS<->Flash communications. Perhaps there will be a change to the ExternalInterface code in the future that will play nice with IE.

    James – I’m glad my work is helping you! You should take a look at Tera-WURFL 1.5.2 – it’s much better then previous versions.

    Let me know if you need help with anything.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s