<?PHP
$html="<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<meta http-equiv=content-type content=\"text/html; charset=iso-8859-1\">
<title>gd+ming</title>
<style type=\"text/css\">
.localbody{background-color:#000;}
</style>
</head>
<body class=\"localbody\">
<div align=\"center\">
<br>
<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"300\" height=\"150\" id=\"gd+ming\" align=\"\">
<param name=movie value=\"gd+ming.php?view_swf=1\">
<param name=quality value=high>
<param name=scale value=exactfit>
<param name=bgcolor value=#FFFFFF>
<embed src=\"gd+ming.php?view_swf=1\" quality=high scale=exactfit bgcolor=#FFFFFF width=\"300\" height=\"150\" name=\"gd+ming\" align=\"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"></embed>
</object><br>
</div>
</body>
</html>";
if(!$_GET['view_swf'])
{
//print html page
echo $html;
}else if($_GET['view_swf']==1)
{
if(!extension_loaded('ming'))
{
dl('php_ming.so');
}
if(!extension_loaded('gd'))
{
dl('php_gd.so');
}
// GD methods
$PNG_1='./square.png';
$PNG_2=ImageCreateFromPNG($PNG_1);
$width=imagesx($PNG_2);
$height=imagesy($PNG_2);
$colors_obj=ImageCreateTrueColor($width,$height);
ImageCopyMerge($colors_obj,$PNG_2,0,0,0,0, $width,$height,100);
ImageTrueColorToPalette($PNG_2,true,256);
ImageColorMatch($colors_obj,$PNG_2);
// create /tmp/spider_transparent.png
$mask=ImageColorClosest($PNG_2,0,0,0);
ImageColorTransparent($PNG_2,$mask);
Imagepng($PNG_2,"/tmp/square_transparent.png");
// Ming methods
Ming_setScale(20.0);
ming_useswfversion(6);
$mov=new SWFMovie();
$mov->setDimension($width*2,$height);
$mov->setBackground(255,255,255);
$mov->setRate(31);
$BMPshape=new SWFBitmap(fopen("./square.png","rb"));
$BMPsprite=new SWFSprite();
$BMPsprite->add($BMPshape);
$BMPsprite->nextFrame();
$BMPclip=$mov->add($BMPsprite);
$BMPclip->moveTo(0,0);
$BMPclip->setName("square_mc");
// load bitmap to clip
$BMPshape=new SWFBitmap(fopen("/tmp/square_transparent.png","rb"));
$BMPsprite=new SWFSprite();
$BMPsprite->add($BMPshape);
$BMPsprite->nextFrame();
// set bitmap sprite to clip
$BMPclip=$mov->add($BMPsprite);
$BMPclip->moveTo($width,0);
$BMPclip->setName("square_transparent_mc");
/////// mxFlash 6 actionscript ///////
$ActionScript="
// AS only
_root.sound_mp3_mc=new Sound();
_root.sound_mp3_mc.loadSound(\"./bip.mp3\",false);
_root.createEmptyMovieClip(\"square_small_mc\",1);
_root.square_small_mc.createEmptyMovieClip(\"img_mc\",2);
_root.square_small_mc.img_mc.loadMovie(\"./square_small.jpeg\");
_root.onEnterFrame=function()
{
if (_root.square_small_mc._width>0)
{
delete _root.onEnterFrame;
_root.square_small_mc._x=110;
_root.square_small_mc._y=90;
}
};
_root.square_small_mc.onPress=function()
{
this._alpha=50;
this.startDrag('');
};
_root.square_small_mc.onRelease=function()
{
this._alpha=100;
this.stopDrag('');
};
// Ming SWFSprite square_transparent_mc
_root.square_transparent_mc.onPress=function()
{
_root.sound_mp3_mc.start();
this._alpha=50;
_root.square_small_mc._x=190;
_root.square_mc._alpha=80;
this.startDrag('');
};
_root.square_transparent_mc.onRelease=function()
{
_root.sound_mp3_mc.stop();
this._alpha=100;
this._x=150;
this._y=0;
_root.square_small_mc._x=110;
_root.square_small_mc._y=90;
_root.square_mc._alpha=100;
this.stopDrag('');
};
";
$mov->add(
new SWFAction(
$ActionScript
)
);
header('Content-type: application/x-shockwave-flash');
$mov->output();
ImageDestroy($PNG_2);
imagedestroy($colors_obj);
unlink('/tmp/square_transparent.png');
}
?>