$totalSWFObjects = 0; foreach ($xml->svg as $svg) { if ($svg['t'] != 'f') { if ($charid != null || $chardepth != null) { for ($p = 0; $p <= $totalSWFObjects - 1; $p++) { $swf->RemoveObjectFromLayer($charid[$p], $chardepth[$p]); } } } foreach ($svg->line as $line) { $linefillColor = rgbConvert($line['stroke']); $CharacterInfo = $swf->DefineStraightLine($line['x1'] * 20, $height * 20 - $line['y1'] * 20, $line['x2'] * 20, $height * 20 - $line['y2'] * 20, $line['stroke-width'] * 20, false, $linefillColor[0], $linefillColor[1], $linefillColor[2], 0); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); $charid[$totalSWFObjects] = $CharacterInfo["CharacterID"]; $chardepth[$totalSWFObjects] = $CharacterDepth; $totalSWFObjects++; } foreach ($svg->rect as $rect) { $rectfillColor = rgbConvert($rect['fill']); $rectlineColor = rgbConvert($rect['stroke']); $CharacterInfo = $swf->DefineRectangleSolid($rect['x'] * 20, $height * 20 - $rect['y'] * 20, $rect['x'] * 20 + $rect['width'] * 20, $height * 20 - ($rect['y'] * 20 + $rect['height'] * 20), $rect['stroke-width'] * 2, false, true, $rectlineColor[0], $rectlineColor[1], $rectlineColor[2], 255, true, $rectfillColor[0], $rectfillColor[1], $rectfillColor[2], 255); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); $charid[$totalSWFObjects] = $CharacterInfo["CharacterID"]; $chardepth[$totalSWFObjects] = $CharacterDepth; $totalSWFObjects++; } $swf->EndFrame(); } $swf->EndMovie(); echo $swf->GetMovie();
$y2 = $cheight - ($shape["top"] + $shape["height"]); $lw = $shape["lineWidth"]; $fillArray = sscanf($shape['fillColor'], '#%2x%2x%2x'); $strokeArray = sscanf($shape['lineColor'], '#%2x%2x%2x'); $CharacterInfo = $swf->DefineRectangleSolid($x1 * 20, $y1 * 20, $x2 * 20, $y2 * 20, $lw * 20, false, true, $strokeArray[0], $strokeArray[1], $strokeArray[2], 255, true, $fillArray[0], $fillArray[1], $fillArray[2], $fillArray[3]); //$CharacterInfo = $swf->DefineRectangle($x1*20, $y1*20, $x2*20, $y2*20, $lw*20, false, $strokeArray[0], $strokeArray[1], $strokeArray[2], 255); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); array_push($previous_id_array, $CharacterInfo["CharacterID"]); array_push($previous_depth_array, $CharacterDepth); break; case "line": $x1 = $shape["left"]; $y1 = $cheight - $shape["top"]; $x2 = $shape["left"] + $shape["width"]; $y2 = $cheight - ($shape["top"] + $shape["height"]); $strokeArray = sscanf($shape['lineColor'], '#%2x%2x%2x'); $CharacterInfo = $swf->DefineStraightLine($x1 * 20, $y1 * 20, $x2 * 20, $y2 * 20, $shape["lineWidth"] * 20, false, $strokeArray[0], $strokeArray[1], $strokeArray[2], 0); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); array_push($previous_id_array, $CharacterInfo["CharacterID"]); array_push($previous_depth_array, $CharacterDepth); break; } } $swf->EndFrame(); } $swf->EndMovie(); $animation = $swf->GetMovie(); echo base64_encode($animation); ?>
//------------------------------------------------------- // import the FreeMovieCompilerTollbox require_once "freemoviecompilertoolbox.php"; //------------------------------------------------------- // initialize new SWF object. $swf = new FreeMovieCompilerToolbox(); //------------------------------------------------------- // set the global parameters of your movie // frame size is in twips (1 twip = 20 pixels) $swf->SetSWFVersion(5); $swf->SetFrameSize(16000, 12000); // = 800 x 20, 600 x 20 $swf->SetFrameRate(24.0); $swf->SetBackgroundColor(255, 255, 255); //------------------------------------------------------- // lights! camera! action! $swf->BeginMovie(); //------------------------------------------------------- // frame # 00000 $CharacterInfo = $swf->DefineCurvedLine(2000, 2000, 3000, 6000, 4000, 2000, 300, false, 0, 0, 0, 0); $CharacterDepth = $swf->EasyPlaceObject($CharacterInfo["CharacterID"]); //------------------------------------------------------- // end frame # 00000 $swf->EndFrame(); //------------------------------------------------------- // That's it, Folks! $swf->EndMovie(); //------------------------------------------------------- // send movie to the browser print $swf->GetMovie(); exit;
if ($type == "export") { $fileDir = "files"; if ($_REQUEST['filename'] != null) { $SWFFileName = $_REQUEST['filename']; } else { $SWFFileName = "file-{$zhash}"; } } else { $fileDir = "preview"; $SWFFileName = "file-{$zhash}"; } $ourFileName = "{$fileDir}/{$SWFFileName}.swf"; $filename = "{$fileDir}/{$SWFFileName}.swf"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); $somecontent = $swf->GetMovie(); if (is_writable($filename)) { if (!($handle = fopen($filename, 'a'))) { echo "Cannot open file ({$filename})"; //exit; } if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ({$filename})"; //exit; } echo "{$filename}"; fclose($handle); } else { echo "The file {$filename} is not writable"; } if ($enable_logging == true) {