homepage Welcome to WebmasterWorld Guest from 54.227.5.234
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
how to make HTML link with swf object?
i_am_dhaval




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

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>

 

rocknbil




msg:4014384
 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;

i_am_dhaval




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

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

rocknbil




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

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 = (
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>';
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved