Forum Moderators: open
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>
<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;
$types = (
0=>'jpg',
1=>'swf'
);
(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>';
}