Un amigo con una conexión de 2 megas también me dijo que le demoró minutos en cargar. Evidentemente el hecho de que demore mas de 20 segundos ya está dando la pauta de que no funciona como debería.
CODIGO DEL FLASH, EL "PRINT"
Código:
import it.sephiroth.mloaderWindow
import it.sephiroth.PrintScreen
var loader:mloaderWindow = this.createClassObject(mloaderWindow, "loader", 10, {_x:-1000, _y:-1000})
loader.setStyle("borderColor", 0x006699)
// listener which receives the broadcast message
// from the PrintScreen class
var listener:Object = new Object();
// copy in progress...
listener.onProgress = function(target:MovieClip, loaded:Number, total:Number){
var perc = Math.round((loaded/total)*100)
loader.label = "GUARDANDO... " + perc + "%"
loader.value = perc
}
// copy is complete, send the result LoadVars to PHP
listener.onComplete = function(target:MovieClip, load_var:LoadVars){
loader.label = "espera un segundo..."
load_var.send("files/guardame-soytapa.php", "POST")
loader.close()
}
/**
* Print Button has been clicked
*/
function print_me(){
pn = new PrintScreen(); // initialize the PrintScreen class
pn.addListener( listener ); // assign a listener
pn.print(this,0,0,530,485); // copy the _root
loader.label = "GUARDANDO... 0%"
loader.open(true, true, true); // open a loader
}
RECIBE EL CODIGO DEL GENERADOR PHP:
Código PHP:
<?php
error_reporting(0);
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
//SI ESTAN DEFINIDAS VARIABLES DESDE FLASH
if (isset($_POST['width'])&& $_POST['height']!="") {
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];
// create the image with desired width and height
$img = imagecreatetruecolor($w, $h);
// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($img, 0, 0, 0xFFFFFF);
$rows = 0;
$cols = 0;
// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($img, $cols, $rows, $test);
}
}
}
// print out the correct header to the browser
header("Content-type:image/jpeg");
// display the image
imagejpeg($img, "", 90);
imagedestroy($img);
} else {
echo '<HEAD><META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.fumarpaco.com.ar/soytapa/"></HEAD><body>
<h1><a href="http://www.fumarpaco.com.ar/soytapa/">CREAR MI TAPA DE REVISTA, SOY TAPA</a></h1></body> ';
} // Cierre del else
?>