Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

how to make HTML link with swf object?



11:37 am on Oct 27, 2009 (gmt 0)

10+ Year Member

here is my code..

i need to add link in .swf file

what is the error in my code?

<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='simplemovie1' ALIGN='' style="width: 187px; height: 69px"> <param name='movie' value='home_add/1-1.jpg'> <param name='quality' value=medium> <param name='bgcolor' value=#FFFFFF> <param name='wmode' value='transparent' /> <embed src='../home_add/1-1.jpg' quality=medium swliveconnect='true' bgcolor=#FFFFFF name='simplemovie1' align='' TYPE='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'> </embed></OBJECT>


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

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

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'>


<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:


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>


<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'); }

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;


4:45 am on Oct 28, 2009 (gmt 0)

10+ Year Member

in my application..user will upload there advertising which is Jpg Or SWF..now when user upload it then i want to add url..but when in front end link is not working properly..when user upload jpg or swf...


4:16 pm on Oct 28, 2009 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Well, in that case, in your programming, you're going to have to do something like this. (PHP-ish code, everyone seems to like that better)

$types = (
(using an associative just so you know what is what)

if ($upload_type==0) {
// write out img code
echo '<a href="' . $user_url .'"><img srg="' . $user_image ."></a>';
else if ($upload_type==1) {
// write out SWF code
// echo out the SWFObject code above
else {
echo '<p>Only ' . $types[0] . ' or ' . $types[1] . ' are allowed.</p>';


Featured Threads

Hot Threads This Week

Hot Threads This Month