Click to See Complete Forum and Search --> : How to call url by clicking on .swf file not internally but externally in html page

01-17-2007, 05:38 AM
I have embed flash file in the html page. I want to call a URL throgh HTML only not through flash .swf file.

Is it possible??

Is it possible to open the URL by clicking on the flash file in html page instead of giving script inside the flash file i want to give it in the html page.

Pls do write the code for me


01-17-2007, 10:59 AM

I think this is a little fiddly, you can't simply wrap an <a> element around the movie, nor can you use javascript to capture mouse events over the movie. What you could try is creating a transparent clickable "proxy" element over the top of the movie. Here's an example. Let's say your movie you want to be clickable has an id attribute of clickable-movie

You could have something like this in the <head> of your page to make clicking "on" the movie goto google,

<style type="text/css">
.clickable-proxy {
display: block;
position: absolute;
zIndex: 99999;
background: #fff;
/* make the proxy transparent across different browsers */
opacity: 0.0;
-moz-opacity: 0.0;
filter: alpha(opacity=0);

<script type="text/javascript">
var getElementPos = function(obj) {
var x = 0; var y = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
x += obj.offsetLeft;
y += obj.offsetTop;
obj = obj.offsetParent;
return {x: x, y: y};

var createObjectProxy = function(x, y, w, h, href) {
var proxy = document.createElement('a');
proxy.className = 'clickable-proxy';
with (proxy.style) {
left = (x - 5) + 'px';
top = (y - 5) + 'px';
width = (w + 10) + 'px';
height = (h + 10) + 'px';
proxy.href = href;


onload = function() {
var obj = document.getElementById('clickable-movie');
var coords = getElementPos(obj);
createObjectProxy(coords.x, coords.y, obj.offsetWidth, obj.offsetHeight, 'http://www.google.com');