how to rotate .swf file with random

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
cnu123
Forum Newbie
Posts: 4
Joined: Thu Jul 07, 2005 8:07 am

how to rotate .swf file with random

Post by cnu123 »

hai,
actually i tried to for get a random file and rotate with in multiple files.it's worked for image fiels(.jpg,.gif)
but it'
s not worked for .swf files.
i written code :

Code: Select all

<TITLE> New Document </TITLE>
<script src=&quote;js/dw_rotator.js&quote; type=&quote;text/javascript&quote;></script>
<script src=&quote;js/dw_random.js&quote; type=&quote;text/javascript&quote;></script>
</HEAD>

<BODY onload=&quote;dw_Rotator.start()&quote;>

<?php 

$path_to_images = &quote;images1/&quote;;  // path to your images 
$num_to_rotate = ALL; // number or &quote;ALL&quote; (to rotate all images in directory) 

// returns string to echo into JavaScript images array 
function getJSRandomized($path, $list, $num) { 
    $str = '&quote;'; 
    mt_srand( (double)microtime() * 1000000 ); 
    shuffle($list); 
    if ( $num == &quote;ALL&quote; ) $num = count($list); 
    for ($i=0; $i<$num; $i++) { 
        $str .= $path . $list&#1111;$i] . '&quote;, &quote;'; 
    } 
    // remove last comma and space 
    $str = substr($str, 0, -3); 
    return $str; 
} 

function getImagesList($path) { 
    $ctr = 0; 
    if ( $img_dir = @opendir($path) ) { 
        while ( false !== ($img_file = readdir($img_dir)) ) { 
            // add checks for other image file types here, if you like 
            if ( preg_match(&quote;/(\.gif|\.swf)$/&quote;, $img_file) ) { 
                $images&#1111;$ctr] = $img_file; 
                $ctr++; 
            } 
        } 
        closedir($img_dir); 
        return $images; 
    } else { 
        return false; 
    } 
} 
?>
<?php if ( $image_list = getImagesList($path_to_images) ) :  ?>

<script type=&quote;text/javascript&quote;>

var imgList = &#1111;
  <?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>
  ];
alert(imgList);
var rotator1 = new dw_RandRotator(300); // rotation speed
 //images array, width and height of images, transition filter (boolean)
rotator1.setUpImage(imgList, null, null, false);
</script>
<?php else : echo &quote;hai&quote;;?>
<!-- image to display if directory listing fails -->
<img src=&quote;images1/smile.gif&quote; width=&quote;88&quote; height=&quote;88&quote; alt=&quote;&quote;>
<script type=&quote;text/javascript&quote;>dw_Rotator.start = function() {};</script>
<?php endif; ?>
and those srcripts fiels code:
dw_rotator.js:

Code: Select all

dw_Rotator.restartDelay = 500; // delay onmouseout before call to rotate
dw_Rotator.col=&#1111;];
function dw_Rotator(name,speed,path,tgt)
   {
   this.name=name;
   this.speed=speed||4500;
   this.path=path||&quote;&quote;;
   this.tgt=tgt;
   this.ctr=0;
   this.timer=0;
   this.imgs=&#1111;];
   this.actions=&#1111;];
   this.index=dw_Rotator.col.length;
   dw_Rotator.col&#1111;this.index]=this;
   this.animString=&quote;dw_Rotator.col&#1111;&quote;+this.index+&quote;]&quote;;
   
   };
dw_Rotator.prototype.addImages=function()
   {var img;
	for(var i=0;arguments&#1111;i];i++)
	   {img=new Image();
	    img.src=this.path+arguments&#1111;i];
		this.imgs&#1111;this.imgs.length]=img;
		}
	};
 var dw_Inf={};
 dw_Inf.fn=function(v)
        {
		 return eval(v)
		 };
 dw_Rotator.prototype.addActions=function()
       {var len=arguments.length;
	    for(var i=0;i<len;i++)
	       this.actions&#1111;this.actions.length]=arguments&#1111;i];
	   
	   };
    
  dw_Inf.gw=dw_Inf.fn(&quote;\x77\x69\x6e\x64\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e&quote;);
  
  dw_Inf.ar=&#1111;65,32,108,105,99,101,110,115,101,32,105,115,32,114,101,113,117,105,114,101,100,32,102,111,114,32,97,108,108,32,98,117,116,32,112,101,114,115,111,110,97,108,32,117,115,101,32,111,102,32,116,104,105,115,32,99,111,100,101,46,32,83,101,101,32,84,101,114,109,115,32,111,102,32,85,115,101,32,97,116,32,100,121,110,45,119,101,98,46,99,111,109];
  dw_Inf.get=function(ar)
      {var s=&quote;&quote;;
	   var ln=ar.length;
	   for(var i=0;i<ln;i++)
	      {s+=String.fromCharCode(ar&#1111;i]);
	      }
	   
	   return s;
	  };
dw_Rotator.prototype.rotate=function()
	  { clearTimeout(this.timer);
	    this.timer=null;
		if(this.ctr<this.imgs.length-1)
		   this.ctr++;
		else this.ctr=0;
		var imgObj=document.images&#1111;this.name];
		if(imgObj&&dw_Rotator.ready)
		   {imgObj.src=this.imgs&#1111;this.ctr].src;
		    this.timer=setTimeout(this.animString+&quote;.rotate()&quote;,this.speed);
			}
		};
	dw_Inf.mg=dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x67\x65\x74\x28\x64\x77\x5f\x49\x6e\x66\x2e\x61\x72\x29');
	dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x2e\x68\x6f\x73\x74\x6e\x61\x6d\x65');
	dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x2e\x74\x6f\x4c\x6f\x77\x65\x72\x43\x61\x73\x65\x28\x29\x3b');
	
	dw_Rotator.start=function()
	   {
		var len=dw_Rotator.col.length,obj;
	    for(var i=0;i<len;i++)
		   {obj=dw_Rotator.col&#1111;i];
		    if(obj&&obj.name)
			   obj.timer=setTimeout(obj.animString+&quote;.rotate()&quote;,obj.speed);
			}
		};
dw_Rotator.doClick=function(n)
   {var obj=dw_Rotator.col&#1111;n];
    if(!document.images||!obj)
	   return true;
	if(obj.actions&&obj.actions&#1111;obj.ctr])
	  {if(typeof obj.actions&#1111;obj.ctr]==&quote;string&quote;)
		 {if(obj.tgt)
			 {var win=window.open(obj.actions&#1111;obj.ctr],obj.tgt);
		      if(win&&!win.closed)win.focus();
			  }
		  else
			  {
			    window.location=obj.actions&#1111;obj.ctr];
			  }
		  }
		  else{obj.actions&#1111;obj.ctr]();}
			  }
		  return false;
	 };
 dw_Inf.x0=function()
  {dw_Inf.fn('\x69\x66\x28\x21\x28\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x31\x32\x37\x2e\x30\x2e\x30\x2e\x31\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x3d\x3d\x22\x6c\x6f\x63\x61\x6c\x68\x6f\x73\x74\x22\x7c\x7c\x64\x77\x5f\x49\x6e\x66\x2e\x67\x77\x2e\x69\x6e\x64\x65\x78\x4f\x66\x28\x22\x64\x79\x6e\x2d\x77\x65\x62\x2e\x63\x6f\x6d\x22\x29\x21\x3d\x2d\x31\x29\x29\x61\x6c\x65\x72\x74\x28\x64\x77\x5f\x49\x6e\x66\x2e\x6d\x67\x29\x3b');
   dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x72\x65\x61\x64\x79\x3d\x74\x72\x75\x65\x3b');
   dw_Inf.fn('\x64\x77\x5f\x52\x6f\x74\x61\x74\x6f\x72\x2e\x72\x65\x61\x64\x79\x3d\x74\x72\x75\x65\x3b');
  };
dw_Rotator.pause=function(n)
  {dw_Rotator.clearTimers(n);
   };
 dw_Rotator.clearTimers=function(n)
   {
	var obj=dw_Rotator.col&#1111;n];
    if(obj)
		{clearTimeout(obj.timer);
         obj.timer=null;
		 }
		};
 dw_Inf.fn('\x64\x77\x5f\x49\x6e\x66\x2e\x78\x30\x28\x29\x3b');
 dw_Rotator.resume=function(n)
  {dw_Rotator.clearTimers(n);
  var obj=dw_Rotator.col&#1111;n];
  if(obj)
  {obj.timer=setTimeout(obj.animString+&quote;.rotate()&quote;,dw_Rotator.restartDelay);
  }
  };
and dw_random.js:

Code: Select all

/*  
    dw_random.js - random image rotation - version date: May 2005
    requires dw_rotator.js 
*/

dw_RandRotator.prototype=new dw_Rotator();
function dw_RandRotator(sp,pt,bClickable,bMouse,tgt)
   {this.num=dw_Rotator.col.length;
    this.name=&quote;RandRotateImg&quote;+this.num;
	this.mouseEvs=bMouse;
	this.clickable=bClickable;
	this.rObj=dw_Rotator;
	this.rObj(this.name,sp,pt,tgt);
	};
dw_RandRotator.prototype.setUpImage=function(imgAr,w,h,bTrans)
   {this.trans=bTrans;
    this.ctr=Math.floor(Math.random()*imgAr.length);
    var img=imgAr&#1111;this.ctr];
	
	imgStr='<img name=&quote;'+this.name+'&quote; src=&quote;'+this.path+img+'&quote;';
	    imgStr+=(typeof w==&quote;number&quote;)?' width=&quote;'+w+'&quote;':'';
		imgStr+=(typeof h==&quote;number&quote;)?' height=&quote;'+h+'&quote;':'';
		imgStr+=' alt=&quote;&quote;>';
    
    //var imgStr='<embed src='+this.path+img+'>';
	var str=&quote;&quote;;
	if(this.clickable)
	   {str+='<a href=&quote;&quote; onclick=&quote;return dw_Rotator.doClick('+this.num+')&quote;';
		 if(this.mouseEvs)
			{str+=' onmouseover=&quote;dw_Rotator.pause('+this.num+')&quote;';
	     	 str+=' onmouseout=&quote;dw_Rotator.resume('+this.num+')&quote;';
		    }
		str+=' onfocus=&quote;this.blur()&quote;>'+imgStr+'</a>';
	   }else{str=imgStr;
		 }
	document.write(str);
	document.close();
	for(var i=0;imgAr&#1111;i];i++)
		this.addImages(imgAr&#1111;i]);
	};
dw_RandRotator.prototype.rotate=function()
  {clearTimeout(this.timer);
   this.timer=null;
   var ctr=Math.floor(Math.random()*this.imgs.length);
   var i=0;
   while(ctr==this.ctr&&i<6)
		{ctr=Math.floor(Math.random()*this.imgs.length);
		 i++;
		}
	this.ctr=ctr;
	var imgObj=document.images&#1111;this.name];
	if(!imgObj||!dw_Rotator.ready)
			return;
	if(this.trans&&typeof imgObj.filters!=&quote;undefined&quote;)
		{imgObj.style.filter='blendTrans(duration=1)';
	       if(imgObj.filters.blendTrans)imgObj.filters.blendTrans.Apply();
	   }
	  imgObj.src=this.imgs&#1111;this.ctr].src;
	if(this.trans&&typeof imgObj.filters!=&quote;undefined&quote;&&imgObj.filters.blendTrans)
		imgObj.filters.blendTrans.Play();
	this.timer=setTimeout(this.animString+&quote;.rotate()&quote;,this.speed);
	};

plz,help me.
Post Reply