Difference between revisions of "Compile-swf.php"

From Organic Design wiki
(Old Ming compile code)
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{legacy}}
 +
<source lang="php">
 
<html>
 
<html>
 
<head><title>Sic Games</title></head>
 
<head><title>Sic Games</title></head>
Line 99: Line 101:
 
}
 
}
 
?>
 
?>
 +
</source>

Latest revision as of 02:37, 23 April 2020

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.
<html>
<head><title>Sic Games</title></head>
<body bgcolor="black"><font face="courier new" color="#00ff">
<center><font face='sans-serif' size=10>Compiling Sickness</font></center><br><br>
<?
if (isset($HTTP_GET_VARS['test'])) $test='test_'; else $test='';
$t = "&nbsp;&nbsp;&nbsp;";

// _____________________________________________________________________________________________________________________ //

# Check weather required extentions are available (GD2 and Ming)
print "Checking PHP extentions...<br>";
$ext = get_loaded_extensions();
if (!in_array('gd', $ext)) print "Warning: GD extention not loaded! (image processing unavailable)<br>";
else {
	$gdi = gd_info();
	ereg('([0-9])([0-9.]+)', $gdi['GD Version'], $m);
	print $t."GD Version is $m[1]$m[2]<br>";
	if ($m[1] < 2) print "Warning: At least GD version 2 required (image processing unavailable)<br>";
	else print $t."GD extention ok.<br>";
	}
if (!in_array('ming', $ext)) die("Fatal: Ming extention not loaded! (at least version 0.3 required)");
else print $t."Ming extention ok.<br>";
// _____________________________________________________________________________________________________________________ //

$start = getmicrotime();

# Compile ./interface.swf
ming_useswfversion(6);
$swf=new SWFMovie();
$swf->setDimension(1024, 768);
$swf->setBackground(0,0,0);
$swf->setRate(50);

# Build symbols from bitmap (png) sequence sets
buildVectorSymbols($swf, './ming_scripts');
$swf->writeExports();

# Give actionscript access to symbol library
$actionscript = array();

// Scan swf's and supply a list of them
$actionscript[1] = "bgList = [];swfList = [];";
if ($xswf = opendir('./swf')) {
	while (false !== ($xsh = readdir($xswf))) {
		if (ereg('^bg', $xsh)) $actionscript[1] .= "bgList.push('$xsh');\n";
		if (ereg('^obj', $xsh)) $actionscript[1] .= "swfList.push('$xsh');\n";
		}
	closedir($xswf);
	}

# Import external actionscript frames
$frames = 1;
while (file_exists("./frame$frames.as")) $frames++;
for ($frame = 1; $frame <= $frames-1; $frame++) {
	if ($frame > 1) $actionscript[$frame]='';
	$actionscript[$frame] .= implode('', file("./frame$frame.as"));
	$swf->add(new SWFAction($actionscript[$frame]));
	$swf->nextFrame();
	}

# Output as compressed SWF file
$swf->save('./interface.swf',9);
	//header('Content-type: application/x-shockwave-flash');
	//$swf->output();
echo "\nCompiling $test"."interface.swf (".round(filesize("./$test"."interface.swf")/1024+.5)."KB, ".round(getmicrotime()-$start,2)."s)<br>";
	?><input id="runbutton" type="button" value="  Sic  " onClick="runit()">
	<script language="javascript">
	runbutton.focus();
	function runit() {
	//window.open('./interface.swf','SicGames','width='+(screen.width-10)+',height='+(screen.height-30)+',screenx=0,screeny=0,directories=0,fullscreen=1,location=0,menubar=0,scrollbars=0,status=0,toolbar=0');
	window.open('./interface.swf','SicGames','width=512,height=384,directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0');
	}
	</script><?
// _____________________________________________________________________________________________________________________ //

# Close HTML page
?></font></body></html><?

// _____________________________________________________________________________________________________________________ //

function getmicrotime() { 
    list($usec, $sec) = explode(" ", microtime()); 
    return ((float)$usec + (float)$sec); 
	} 

# Build a vector symbol by importing and executing php-ming scripts from passed path
function buildVectorSymbols($swf, $path) {
	$inc = '';
	if ($dh = opendir($path)) {
		while (false !== ($file = readdir($dh))) if (eregi('^(.+).php$', $file, $m)) {
			print "Ming vector script: &quot;$m[1]&quot;<br>";
			$inc .= implode('', file("$path/$file"));
			}
		closedir($dh);
		}
	eval($inc);
	print "<br>";
	}
?>