Dengan script ini kita bisa membuat tombol untuk zoom out/ in sebuah embed game flash. Langkah pertama copy script dibawah ini dan paste diatas tag </head>.
=============================================
<script type="text/javascript">
var startGameWidth = 640;
var startGameHeight = 480;
var maxGameWidth = 1000;
var minGameHeight = 300;
var n = 1;
var p = 1;
function upSize(divID)
{
var newWidth = Math.round(20 * p) + startGameWidth;
var newHeight = Math.round(20 * p) + startGameHeight;
if(newWidth > maxGameWidth){
p=n;
} else {
p=++n;
}
document.getElementById(divID).style.width = newWidth+ "px";
document.getElementById(divID).style.height = newHeight+ "px";
}
function downSize(divID)
{
p=p-1;
var newWidth = Math.round(20 * p) + startGameWidth;
var newHeight = Math.round(20 * p) + startGameHeight;
if(newHeight < minGameHeight){
p=n;
} else if(newWidth > maxGameWidth) {
p=--n;
} else {
p=--n;
}
document.getElementById(divID).style.width = newWidth+ "px";
document.getElementById(divID).style.height = newHeight+ "px";
}
function resetSize(divID)
{
p=1;
n=1;
document.getElementById(divID).style.width = startGameWidth+ "px";
document.getElementById(divID).style.height = startGameHeight+ "px";
}
</script>
============================================
Kemudian copy script dibawah ini dan paste didalam tag <body>
============================================
<input type="text" name="clicked" id="clicked">
<input type="button" value="+" onclick="upSize('gambar')" />
<input type="button" value="-" onclick="downSize('gambar')" />
<input type="button" value="Reset" onclick="resetSize('gambar')" />
<div id="gambar" style="width: 640px; height: 480px;border:1px solid black">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100%" height="100%"><param name="src" value="http://www.2flashgames.com/2fgkjn134kjlh1cfn81vc34/flash/f-Rasta-Gran-78004.swf">
<embed src="http://www.2flashgames.com/2fgkjn134kjlh1cfn81vc34/flash/f-Rasta-Gran-78004.swf" width="100%" height="100%" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ></embed></object>
</div>
============================================
Selesai. Silahkan mencoba :)
=============================================
<script type="text/javascript">
var startGameWidth = 640;
var startGameHeight = 480;
var maxGameWidth = 1000;
var minGameHeight = 300;
var n = 1;
var p = 1;
function upSize(divID)
{
var newWidth = Math.round(20 * p) + startGameWidth;
var newHeight = Math.round(20 * p) + startGameHeight;
if(newWidth > maxGameWidth){
p=n;
} else {
p=++n;
}
document.getElementById(divID).style.width = newWidth+ "px";
document.getElementById(divID).style.height = newHeight+ "px";
}
function downSize(divID)
{
p=p-1;
var newWidth = Math.round(20 * p) + startGameWidth;
var newHeight = Math.round(20 * p) + startGameHeight;
if(newHeight < minGameHeight){
p=n;
} else if(newWidth > maxGameWidth) {
p=--n;
} else {
p=--n;
}
document.getElementById(divID).style.width = newWidth+ "px";
document.getElementById(divID).style.height = newHeight+ "px";
}
function resetSize(divID)
{
p=1;
n=1;
document.getElementById(divID).style.width = startGameWidth+ "px";
document.getElementById(divID).style.height = startGameHeight+ "px";
}
</script>
============================================
Kemudian copy script dibawah ini dan paste didalam tag <body>
============================================
<input type="text" name="clicked" id="clicked">
<input type="button" value="+" onclick="upSize('gambar')" />
<input type="button" value="-" onclick="downSize('gambar')" />
<input type="button" value="Reset" onclick="resetSize('gambar')" />
<div id="gambar" style="width: 640px; height: 480px;border:1px solid black">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100%" height="100%"><param name="src" value="http://www.2flashgames.com/2fgkjn134kjlh1cfn81vc34/flash/f-Rasta-Gran-78004.swf">
<embed src="http://www.2flashgames.com/2fgkjn134kjlh1cfn81vc34/flash/f-Rasta-Gran-78004.swf" width="100%" height="100%" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" ></embed></object>
</div>
============================================
Selesai. Silahkan mencoba :)
Tidak ada komentar:
Posting Komentar