Close floating flash advert script

How do I script a button within a floating flash advertisement (embedded in a HTML page by means of layers) to close it (usually denoted by an ‘X’) without exiting the HTML page which embeds it?

Does the button simply make the layer invisible? Any help is appreciated.


Yes, just copy and paste this script in the head of your html (note that te id of the layer containing the banner is “myLayer”)

<script type="text/javascript">
function findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms*[n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers*.document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;

function showHideLayers() { 
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args*))!=null) { v=args[i+2];
    if ( {; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
	//alert("showHideLayers "+obj.visibility);
 function closeBanner(){

and then call the close banner function from your button movieClip in flash:

myCloseButt.onRelease = function(){

Thanks! I’ll give it a shot.


any time