Creating a Flash Pop-Up Ad


<param name="wmode" value="transparent" /> 

With pop-up blockers becoming more and more common in web browsers, creators of web advertisements have to become more creative. One way is to use a neglected feature of Flash movies embedded in the page: When you set the wmode parameter to "TRansparent" as shown in the preceding code, the Flash movie is transparent, so you can place it over the content of the page, creating a pop-up.

The file flashad.swf is a simple Flash animation that includes a button that makes the ad disappear when the user clicks on it. The following ActionScript code (a language also based on ECMAScript) does this by calling JavaScript code in the browser:

on (release) {   getURL("javascript:void(document.getElementById('banner').style.visibility='hidden');"); } 


The code of the page itself is quite similar to the code from the previous phrase: Just as in a sticky navigation, the Flash ad should always be visible.

A Transparent Flash Ad Banner, JavaScript Section (flashad.html; excerpt)

if (window.innerWidth) {   x = window.pageXOffset +     Math.round((window.innerWidth - navwidth) / 2);   y = window.pageYOffset + 10; } else {   with (document.body) {     x = scrollLeft +       Math.round((clientWidth - navwidth) / 2);     y = scrollTop + 10;   } } 

The banner itself resides in a <div> element. Take care that the ID of the banner corresponds to the ID the ActionScript code is trying to make invisible.

A Transparent Flash Ad Banner, HTML Section (flashad.html; excerpt)

<div  style="position: absolute;"> <object class   codebase="http://fpdownload.macromedia.com/pub/   shockwave/cabs/flash/swflash.cab#version=7,0,0,0"   width="400" height="550" >   <param name="movie" value="flashad.swf" />   <param name="quality" value="high" />   <param name="wmode" value="transparent" />   <param name="bgcolor" value="#ffffff" />   <embed src="/books/3/490/1/html/2/flashad.swf" quality="high"       wmode="transparent" bgcolor="#ffffff"       width="400" height="550" name="flashad"       type="application/x-shockwave-flash"       pluginspage="http://www.macromedia.com/go/       getflashplayer" /> </object> </div> 

Figure 5.9 shows the result: The banner resides over the content of the page; also, the background of the Flash movie is transparent.

Figure 5.9. A transparent flash banner.


Warning

Just because Flash ads do not use pop-up windows does not mean that users hate them any less than pop-ups. So use this technique wisely, and make sure that users can actually make the ad invisible. Otherwise, the page content is not visibleand the user and potential customer will become invisible, as well.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net