Ray
Ray

Reputation: 6115

Flash banner, how to give it an (external) html link

Is there a cross-browser solution available to give a flash banner an html link, without putting it into the flash itself? (i.e. the Flash has no clickable button in it)

I tried giving the surrounding anchor tag a high z-index, but that did not work. I'm using the standard google swfobject to include the flash banner, but am not stuck on using that.

Thanks

Upvotes: 0

Views: 999

Answers (2)

Mohsen Khahani
Mohsen Khahani

Reputation: 21

Yes, there is! Here is the trick:

Place your flash banner beside (not inside) the anchor tag and set its wmode="opaque". Also you need to set the position, display and z-index styles of your anchor tag.

<div style="position:relative;">
  <a href="http://your-target-url" style="position:absolute; top:0; left:0; display:block; width:100%; height:100%; z-index:100;">&nbsp;</a>
  <embed src="your-flash-banner" type="application/x-shockwave-flash" wmode="opaque"></embed>
</div>

Edited: To work on IE you have to make it abit dirty. Add one of these styles to the anchor tag too:

background:url(spacer.gif);

where spacer.gif is a 1px transparent gif.

or

background-color:#ffffff; /* the background          */
filter:alpha(opacity=0);  /* Internet Explorer       */
-moz-opacity:0;           /* Mozilla 1.6 and below   */
opacity: 0;               /* newer browser and CSS-3 */

This is another IE bug that does not accept clicks on transparent links with display:block.

Upvotes: 1

meddlingwithfire
meddlingwithfire

Reputation: 1437

Could always have Flash handle the click and pass it up to Javascript through ExternalInterface. Then have your Javascript respond to the call and move the user to the new location. Note, this will only work if the user has Javascript enabled.

Javascript code:

function myCustomFlashCallMethod()
{ alert("Hello world!"); }

Flash Code:

addEventListener(MouseEvent.CLICK, onMouseClick, false, 0, true);

function onMouseClick(event:MouseEvent):void
{
    if (ExternalInterface.available)
    { ExternalInterface.call("myCustomFlashCallMethod"); }
}

ExternalInterface class reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

Adobe's "Using ExternalInterface" write-up: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cb2.html

Upvotes: 1

Related Questions