Compile-swf.php

From Organic Design wiki
Revision as of 06:29, 8 July 2008 by Nad (talk | contribs) ({{legacy}})
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.

<php> Sic Games

Compiling Sickness



"; $ext = get_loaded_extensions(); if (!in_array('gd', $ext)) print "Warning: GD extention not loaded! (image processing unavailable)
"; else { $gdi = gd_info(); ereg('([0-9])([0-9.]+)', $gdi['GD Version'], $m); print $t."GD Version is $m[1]$m[2]
"; if ($m[1] < 2) print "Warning: At least GD version 2 required (image processing unavailable)
"; else print $t."GD extention ok.
"; } if (!in_array('ming', $ext)) die("Fatal: Ming extention not loaded! (at least version 0.3 required)"); else print $t."Ming extention ok.
"; // _____________________________________________________________________________________________________________________ // $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)
"; ?>

<?

// _____________________________________________________________________________________________________________________ //

function getmicrotime() {

   list($usec, $sec) = explode(" ", microtime()); 
   return ((float)$usec + (float)$sec); 

}

  1. 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: "$m[1]"
"; $inc .= implode(, file("$path/$file")); } closedir($dh); } eval($inc); print "
"; } ?> </php>