-
Help with a pre-loader?
Hi all
I've been working on this - www.aegreen.co.uk/creativetech.php for a university assignment. The user creates their own sheep and then has the option of emailing it to themselves. What I'm stuck on is getting a pre-loader to work..
After the sheep is created the user is asked to name the sheep, and when the user clicks next bitmapdata method is used to save a jpg of the sheep to the server. The problem is the php page used to do this opens as a new window in front of the window with the flash application in.
What I'm wondering is, is there a way that this window could not open and instead a pre-loader loaded from 0-100% while the sheep is being saved to the server before going onto the next frame? I've had a play with no success.. Here's some of my code.
This is the actionscript in Flash I'm using to save the JPGS. Found some code for a preloader but it's not working:
Code:
import flash.display.BitmapData;
btn_next.onPress = function() {
output();
gotoandstop(5);
};
function output() {
snap = new BitmapData(305, 290);
snap.draw(mc_modifysheep);
var pixels:Array = new Array();
var w:Number = snap.width;
var h:Number = snap.height;
var z:Number = 0
for (var a = 0; a <= w; a++) {
for (var b = 0; b <= h; b++) {
var tmp = snap.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
perc = int((z * 100)/w)
preloader.perc.text = perc+" %"
preloader.barra._xscale = perc
z++
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
output.height = h;
output.width = w;
output.send("show.php", "output", "POST");
}
stop();
This is the PHP used to actually save the image to disk:
Code:
<?php
$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
$image=imagecreatetruecolor( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$int = hexdec($data[$i++]);
$color = ImageColorAllocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
imagesetpixel ( $image , $x , $y , $color );
}
}
//Output image and clean
header( "Content-type: image/jpeg" );
ImageJPEG( $image, "img/image".uniqid("").".jpg" );
//ImageJPEG( $image )
imagedestroy( $image );
?>
Thanks everyone!
-
hi, try change this line of code:
output.send("show.php", "output", "POST");
to
output.loadVariables ("show.php", "POST");
--
there is a place for those who dare to dream...
Flash Developer
VISTAPARK GMBH
BÄRENSTRASSE 11-13
D-42117 WUPPERTAL
-
tried that, and it doesn't save the sheep to the server anymore
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|