Page is a not externally linkable
- Code, Content, and Presentation
-- Flash and Shockwave
---- how to make HTML link with swf object?


rocknbil - 6:07 pm on Oct 27, 2009 (gmt 0)


I'm not sure what you're asking . . . that is not SWFobject code. (?) That is the old school embed nested in object, and is invalid HTML. Also, the src should be to an swf, not a static image:

<param name='movie' value='home_add/1-1.jpg'>

S/B

<param name='movie' value='your.swf'>

So you want a link to some URL with Flash, is that the question? What I would do is create a transparent box the size of your .swf stage, put it on the bottom layer. Make it a symbol of the button type. Assign an onClick handler to this symbol using getURL().

this.onClick = function() { getURL('file.html'); };

(Note: may have the syntax wrong there, JS and ActionScript are so close I often confuse the two.)

Now, if you want this to be a configurable url without having to edit every .swf, this is where you pass a parameter to Flash externally. That is, let's say you create a variable, "destination"

var destination='file.html';

In your event handler, replace the hard coded URL with the variable:

getURL(destination);

Now all you have to do is pass this as a parameter from your page and the .swf will accept it as the variable.

I could show you how to do that using the code you posted and flashVars, but don't use that. Use SWFObject. It's better in many ways; but using SWFObject, you just have to use addVariable to pass it from your page to your .swf. Completed code, but I don't know the file name of your .swf.

In your web page,

<div id="flash-placeholder"><img src="flash-placeholder.jpg" alt="This image will be replaced by the Flash"></div>

Then,


<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var myVideo = new SWFObject('your.swf', 'objectID', '187', '69', '6', '#ffffff');
myVideo.addParam("wmode", "transparent");
myVideo.addVariable("destination", "http://www.example.com/file.html");
// Note: must use full URL syntax in Flash,
// relative URL's generally don't work
window.onload = function() {
if (document.getElementById('flash-placeholder')) {
myVideo.write('flash-placeholder'); }
};
</script>

When working through it, be sure to remove any value from "destination" from your Flash file so it doesn't overwrite the one being passed from the web page. Just define it in frame 1:

var destination;


Thread source:: http://www.webmasterworld.com/flash/4014171.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com