views:

226

answers:

2

I want to make it so that when I click anywhere on the embedded Flash element, it takes me to a destination URL.

Here is my current code, which does not produce the desired effect:

<div class="contentdiv" style="margin:-72px 0 10px 0px; cursor:pointer;" onclick="location.href='http://example.com/';"&gt;

<object height="410" width="720">
<param name="movie" value="images/tri.swf">
<embed src="images/tri.swf" height="400" width="700"> 
</embed>
</object>

</div>

Right now it is making the space behind the .swf file clickable for the link, but the Flash element is not clickable.

If the right thing to do is to edit the .swf file somehow, please let me know that. I don't consider myself a Flash developer, but are there any resources on where to get started or how to do something this basic with an existing .swf file?

Any suggestions are much appreciated!

+2  A: 

Update after more research:

This question has been asked before, and the best answer is that you have to create the link within flash.

Usually this is done dynamically by passing a parameter (conventionally named clickTAG) to the .swf to tell it where to link to.

In your case (since someone else provided your swf files) I can see 2 options:

  1. Your .swf author may have already implemented the clickTAG method (you can ask them, or just try it out on the .swf to see if it works.)
  2. You could make a flash wrapper file that implements clickTag, and have it load and display your .swf file. I know this seems like a hack, but I can't see any other alternatives.

Hope this helps!


I've also seen something like this used [edit: but I can't get it to work! Googling suggests that it's not possible]

<a href="http://example.com/" target="_blank">
 <object height="410" width="720"><param name="movie" value="images/tri.swf">
 <embed src="images/tri.swf" height="400" width="700"></embed>
 </object>
</a>

(For example here)

Richard Inglis
I tried implementing this and it did not work. Also, your link goes to a forum page that appears un-related to this topic.
JWM
The link is to a page with a flash banner ad: look at the page source to see how they did it!
Richard Inglis
Ok, I looked at the source code, and it's a little unclear because of the way they're setting up that example. They have the <a> tag going around the flash element and the text that comes after it. It's not clear if that <a> tag enables the linking for the flash element or not. For example, it could be because of the <a> tag or it could be because of the way the flash swf file is constructed.In any case, as I explained in my first comment, I tried implementing this with a simple <a> tag as you described, but it did not work. I don't think this is the appropriate fix.
JWM
You're right - I can't make it work either! Maybe there's a reason neither method works, like one of the parameters used to embed the swf? I'll do some more digging...
Richard Inglis
See my revised answer above...
Richard Inglis
Thank you, this helps me get where we need to go.
JWM
A: 

Why not put the code inside your swf?

Is this not an option for some reason?

sberry2A
I would prefer this method because it seems like the most direct and simplest, but I am very unfamiliar with editing swfs. Do you recommend any swf source code editing program, tutorials? Thanks for any direction!
JWM
Ok, I now realize that you cannot just edit a ".swf" file, you need the ".fla" source file, which I do not have because somebody else designed this for me.
JWM