在嵌入的 Flash 文件周围添加链接
我希望这样当我单击嵌入的 Flash 元素上的任意位置时,它会将我带到目标 URL。
这是我当前的代码,它没有产生所需的效果:
<div class="contentdiv" style="margin:-72px 0 10px 0px; cursor:pointer;" onclick="location.href='http://example.com/';">
<object height="410" width="720">
<param name="movie" value="images/tri.swf">
<embed src="images/tri.swf" height="400" width="700">
</embed>
</object>
</div>
现在,它使 .swf 文件后面的空间可单击链接,但 Flash 元素不可单击。
如果正确的做法是以某种方式编辑 .swf 文件,请告诉我。我不认为自己是 Flash 开发人员,但是有关于从哪里开始或如何使用现有 .swf 文件执行此类基本操作的资源吗?
非常感谢任何建议!
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/';">
<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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我遇到了同样的问题,找到了这个线程,但最终创建了我自己的解决方案。
我向链接添加了透明元素,然后使其与嵌入的 swf 重叠。
注意 - 您可能应该将 css 包含在单独的文件中以用于生产代码。
I had the same problem, found this thread, but ended up creating my own solution.
I added transparent element to the link, then made it overlap the embeded swf
Note - you should probably include the css in a separate file for production code.
更多研究后更新:
这个问题之前已经被问过,并且最佳答案是您必须在 Flash 中创建链接。
通常,这是通过将参数(通常称为 clickTAG)传递给 .swf 以告诉它链接到哪里来动态完成的。
对于您的情况(因为其他人提供了您的 swf 文件),我可以看到 2 个选项:
希望这有帮助!
我也见过类似的东西[编辑:但我无法让它工作!谷歌搜索表明这是不可能的]
(例如此处)
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:
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]
(For example here)
使用 z-index 将透明的 .gif 或 .png 文件放在 Flash 上,然后用您的 URL 锚定该透明图像。
Put a transparent .gif or .png file over the flash using z-index and just anchor that transparent image with your URL.
您可以创建自己的 swf(或让别人为您做),其中有一个可编辑的按钮
FlashVars
在舞台上,并在该按钮下方加载您的主题 swf。我为您创建了一个:下载。
您只需在嵌入时添加两个 FlashVar:
url
- 单击 swf 时将访问的 URL。swf
- 要加载的 swf 文件。You could create your own swf (or have someone do it for you) that has a button editable with
FlashVars
over the stage and that loads in your subject swf underneath that button.I've created one for you: Download.
You just need to add two FlashVars when you embed it:
url
- The URL that will be visited if the swf is clicked.swf
- The swf file to load.我很想解决这个问题......我尝试了几种技巧,包括 jquery 和 javascript。
当然,在所有浏览器中都有效的解决方案就是我回复上面的解决方案。
感谢用户user2628529
I got mad to solve the issue.... I tried several tricks including jquery and javascript.
Definitely the SOLUTION that works and works in ALL browser is the one above my reply.
Thanks user user2628529
我找到了一个最好的方法
https://gist.github.com/m-pokrovskii/6558817
There is a best way i've got found
https://gist.github.com/m-pokrovskii/6558817
当然
消除所有情况下的问题
certainly
eliminates the problem in all cases
这对我有用:
This worked for me:
谢谢你!
现在。它起作用了
Thank You!
now. It worked
您无法向 Flash 对象添加链接,但您可以将透明图像与链接重叠在 Flash 对象上。
这是我的示例:
在我的例子中,对象是由脚本嵌入的,但它应该工作相同。
您必须将对象和带有图像的div包裹在相对div中,然后将div定位为绝对,图像按左、上对齐、 right 和bottom 属性,并指定z-index 属性来重叠图像。
You can't add a link to a flash object, but you can overlap a transparent image with a link, over the flash object.
This is my example:
In my case the object is embeded by a script, but it should work the same.
You have to wrap in a relative div the object and a div with the image, and then position as absolute the div with the image aligning it by left, top, right and bottom properties, and asigning z-index property to overlap the image.