how to rotate .swf file with random
Posted: Fri Jul 08, 2005 12:37 am
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 :
and those srcripts fiels code:
dw_rotator.js:
and dw_random.js:
plz,help me.
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="e;js/dw_rotator.js"e; type="e;text/javascript"e;></script>
<script src="e;js/dw_random.js"e; type="e;text/javascript"e;></script>
</HEAD>
<BODY onload="e;dw_Rotator.start()"e;>
<?php
$path_to_images = "e;images1/"e;; // path to your images
$num_to_rotate = ALL; // number or "e;ALL"e; (to rotate all images in directory)
// returns string to echo into JavaScript images array
function getJSRandomized($path, $list, $num) {
$str = '"e;';
mt_srand( (double)microtime() * 1000000 );
shuffle($list);
if ( $num == "e;ALL"e; ) $num = count($list);
for ($i=0; $i<$num; $i++) {
$str .= $path . $listї$i] . '"e;, "e;';
}
// 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("e;/(\.gif|\.swf)$/"e;, $img_file) ) {
$imagesї$ctr] = $img_file;
$ctr++;
}
}
closedir($img_dir);
return $images;
} else {
return false;
}
}
?>
<?php if ( $image_list = getImagesList($path_to_images) ) : ?>
<script type="e;text/javascript"e;>
var imgList = ї
<?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 "e;hai"e;;?>
<!-- image to display if directory listing fails -->
<img src="e;images1/smile.gif"e; width="e;88"e; height="e;88"e; alt="e;"e;>
<script type="e;text/javascript"e;>dw_Rotator.start = function() {};</script>
<?php endif; ?>dw_rotator.js:
Code: Select all
dw_Rotator.restartDelay = 500; // delay onmouseout before call to rotate
dw_Rotator.col=ї];
function dw_Rotator(name,speed,path,tgt)
{
this.name=name;
this.speed=speed||4500;
this.path=path||"e;"e;;
this.tgt=tgt;
this.ctr=0;
this.timer=0;
this.imgs=ї];
this.actions=ї];
this.index=dw_Rotator.col.length;
dw_Rotator.colїthis.index]=this;
this.animString="e;dw_Rotator.colї"e;+this.index+"e;]"e;;
};
dw_Rotator.prototype.addImages=function()
{var img;
for(var i=0;argumentsїi];i++)
{img=new Image();
img.src=this.path+argumentsїi];
this.imgsї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їthis.actions.length]=argumentsїi];
};
dw_Inf.gw=dw_Inf.fn("e;\x77\x69\x6e\x64\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e"e;);
dw_Inf.ar=ї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="e;"e;;
var ln=ar.length;
for(var i=0;i<ln;i++)
{s+=String.fromCharCode(arї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їthis.name];
if(imgObj&&dw_Rotator.ready)
{imgObj.src=this.imgsїthis.ctr].src;
this.timer=setTimeout(this.animString+"e;.rotate()"e;,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їi];
if(obj&&obj.name)
obj.timer=setTimeout(obj.animString+"e;.rotate()"e;,obj.speed);
}
};
dw_Rotator.doClick=function(n)
{var obj=dw_Rotator.colїn];
if(!document.images||!obj)
return true;
if(obj.actions&&obj.actionsїobj.ctr])
{if(typeof obj.actionsїobj.ctr]=="e;string"e;)
{if(obj.tgt)
{var win=window.open(obj.actionsїobj.ctr],obj.tgt);
if(win&&!win.closed)win.focus();
}
else
{
window.location=obj.actionsїobj.ctr];
}
}
else{obj.actionsї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ї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їn];
if(obj)
{obj.timer=setTimeout(obj.animString+"e;.rotate()"e;,dw_Rotator.restartDelay);
}
};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="e;RandRotateImg"e;+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їthis.ctr];
imgStr='<img name="e;'+this.name+'"e; src="e;'+this.path+img+'"e;';
imgStr+=(typeof w=="e;number"e;)?' width="e;'+w+'"e;':'';
imgStr+=(typeof h=="e;number"e;)?' height="e;'+h+'"e;':'';
imgStr+=' alt="e;"e;>';
//var imgStr='<embed src='+this.path+img+'>';
var str="e;"e;;
if(this.clickable)
{str+='<a href="e;"e; onclick="e;return dw_Rotator.doClick('+this.num+')"e;';
if(this.mouseEvs)
{str+=' onmouseover="e;dw_Rotator.pause('+this.num+')"e;';
str+=' onmouseout="e;dw_Rotator.resume('+this.num+')"e;';
}
str+=' onfocus="e;this.blur()"e;>'+imgStr+'</a>';
}else{str=imgStr;
}
document.write(str);
document.close();
for(var i=0;imgArїi];i++)
this.addImages(imgArї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їthis.name];
if(!imgObj||!dw_Rotator.ready)
return;
if(this.trans&&typeof imgObj.filters!="e;undefined"e;)
{imgObj.style.filter='blendTrans(duration=1)';
if(imgObj.filters.blendTrans)imgObj.filters.blendTrans.Apply();
}
imgObj.src=this.imgsїthis.ctr].src;
if(this.trans&&typeof imgObj.filters!="e;undefined"e;&&imgObj.filters.blendTrans)
imgObj.filters.blendTrans.Play();
this.timer=setTimeout(this.animString+"e;.rotate()"e;,this.speed);
};plz,help me.