Thursday, July 05, 2007

Wrapping a Flash SWF <object> with Hyperlink Anchor <a>

The quick answer to this problem (at least if you want browser compatibility): it is impossible - you must have any hyperlink you want your flash to link to to actually be in the flash file itself - that is, you have to make a button and have it be a link in the .FLA or .SWF file itself.  So, if this link has to be set at run-time, you'll need to make a special "Loader" flash file and have it have the transparent button in it.  That part of it is above me (for now).  Maybe I'll write about making one of those when I figure that out.

So, you should know that this does not work after doing a little Googling:

<a href="medium.aspx?id=25">
<object width="200" height="128" quality="Medium" loop="true" play="true"
data="media/static/1_25.swf" id="Flasher1" type="application/x-shockwave-flash"/>
</
a>

What also doesn't work is trying to make a <div>, setting it to position:fixed, and z-index: 10000.  Even if you make the <div>'s background-color transparent, you will no longer be able to see the Flash file (at least in Firefox you won't be able to).

1 comment:

Andras said...

Hmmm.. I don't think so.

You just have to create a transparent gif 1x1 and use the onclick event. This image will be put over the flash object with absolute or relative position and have the width and height just like the flash object. Don't forget to set the param wmode=transparent.

Disqus for A Nofsinger's Blog