PDA

View Full Version : PHP saving



HITMANukas
July 1st, 2005, 04:28 PM
Hello. The main aim of my project is to let users save their flash in png. My flash is like a game to dress all the family members and then save it as a .png picture. The thing is that they choose the clothes from the collection. I have all clothes created in .png. I can send all needed variables for php(for example: var1=shirts1.png, var2=shoes5.png)And I need that php would generate those png in one file. Any help?

beanSoldier
July 1st, 2005, 08:30 PM
use GD. here's a link to get you started:

http://www.phpfreaks.com/tutorials/105/0.php

hl
July 1st, 2005, 09:11 PM
i know GD, but one thing i don't know is how to get an image out of flash. i've been questioning that since i started flash.

Yeldarb
July 1st, 2005, 09:18 PM
hLaLL, there isn't really a way to do that, but if they are .pngs, he can construct it by using those over. Rather than actually sending the image out of flash, you could send the selections for different items (ie "blue hat") as GET or POST variables and make the picture by a set of rules. If they are similar enough, you could just put the hair, face, etc .pngs in the same x/y positions for each image, or you could also send x/y positions for each element to the script out of flash.

hl
July 1st, 2005, 10:01 PM
hLaLL, there isn't really a way to do that, but if they are .pngs, he can construct it by using those over. Rather than actually sending the image out of flash, you could send the selections for different items (ie "blue hat") as GET or POST variables and make the picture by a set of rules. If they are similar enough, you could just put the hair, face, etc .pngs in the same x/y positions for each image, or you could also send x/y positions for each element to the script out of flash.
good point. grr... i've always wanted to create a guestbook that you literally sign.

edit:/ woah, just thought of something, can you tell me how to send the x's and y's through get or post? i'm **** at AS. only good at php :)

bwh2
July 1st, 2005, 10:50 PM
well, if you want to send many x and y variables, you could send those through an array.

beanSoldier
July 1st, 2005, 11:36 PM
load the images externally into flash. then use those same images with GD. just pass the path names to php.

Yeldarb
July 2nd, 2005, 12:03 AM
HlaLL, look up LoadVars in the flash actionscript manual.

bwh2 - Can you do that?

bwh2
July 2nd, 2005, 12:12 AM
bwh2 - Can you do that?i don't see why not, let me try...

Yeldarb
July 2nd, 2005, 12:56 AM
The only way I know of to send an array via http_vars is to make a string and then explode() it once it gets into PHP. But if there's a way to send an array directly, I'd sure like to know it :D
(Especially Multi-Dimensional Arrays... that would make life so much easier)

Jeff Wheeler
July 2nd, 2005, 01:09 AM
Would it not be possible to send the file through POST http request to the php page, just like how you upload a file through a form. PHP can then use the $_FILE predefined variable?

bwh2
July 2nd, 2005, 03:17 AM
well, here's what i did. i got the _x and _y of a mc onClipEvent(enterFrame). i made an array for x, an array for y. sent those arrays from flash to php, php to mysql. i just figured it would be good to save them in a db (thinking in terms of the written guestbook). then i exploded it in php to make an array. i haven't gone farther, but this could be brought back into flash then.

Yeldarb
July 2nd, 2005, 09:37 AM
So you were actually able to send the array data type? What was the format when it got into PHP? Was it still an Array, or was it a string?

gfxwhore
July 2nd, 2005, 11:34 AM
Serialize - look it up. Serializing converts a data type to a binary string that can be stored / sent etc..
I'm pretty sure that flash and php do not use the same serialization so you probably aren't going to be able to unserialize an array serialized in Flash VIA PHP - BUT...you can always use flash to parse the serialized data.

Simple Plan:
Person signs guestbook
Every .1 seconds (you can change to a shorter duration, but size of the array gets bigger), an x/y coord is marked
The array is serialized and sent to PHP via xmlhttprequest, geturl, or whatever you want
The serialized array string is stored somewhere
Then on your guestbook page - flash does an xmlhttprequest,geturl, or whatever you want to get the serialized strings (doesn't have to talk to PHP even, since PHP could have stored them in a text file previously - it can just read that text file)
It unserializes them, then uses some code to map the x/y coords to a drawing (each point should connect to the next point)

Hope I helped ya nubsta :P

bwh2
July 2nd, 2005, 12:53 PM
So you were actually able to send the array data type? What was the format when it got into PHP? Was it still an Array, or was it a string?it was in a string, then i exploded it on "," and threw it into an array. simple enough.

Digitalosophy
July 2nd, 2005, 01:49 PM
At work we render pdf files from Flash. We use an adobe acrobat plug in called DL-100. It's kinda pricey but works great

hl
July 2nd, 2005, 04:40 PM
hold on, i don't know about anything about actionscript. anyone want to show me a sample of sending an array through post?

gfxwhore
July 2nd, 2005, 11:28 PM
Why are you doing flash if you don't know actionscript?
You don't even "need to know". Just use the actionscript manual.

Life is like a box of chocolate.
You need to eat it yourself!

hl
July 2nd, 2005, 11:49 PM
Why are you doing flash if you don't know actionscript?
You don't even "need to know". Just use the actionscript manual.

Life is like a box of chocolate.
You need to eat it yourself! i hardly use flash :P trying to learn.

i love my php though :) btw, i didn't start this thread, somehow it became mine though ;)

bwh2
July 3rd, 2005, 03:26 PM
hold on, i don't know about anything about actionscript. anyone want to show me a sample of sending an array through post?

this is the basic jist of what i did (although mine was a bit different b/c i used a mysql db to store the x and y variables.
[AS]
// this is the movieclip AS //
// mc has instance name "dot" //
onClipEvent(load){
myArrayX = new Array(); // setup x array
myArrayY = new Array(); // setup y array
speed=5; // setup easing speed
}
onClipEvent(enterFrame){
i++;
myArrayX[i] = this._x;
myArrayY[i] = this._y;
this._x+=(_root._xmouse-this._x)/speed; // just making the mc follow the mouse
this._y+=(_root._ymouse-this._y)/speed;
}[/code]


// this is the buttom as to send the array //
on(release){
dot.loadVariables("array_php_test.php", "POST");
}


// php file is named array_php_test.php //
// flash sends the array as a string, so we explode it to put it back into an array //
global $myArrayX;
global $myArrayY;
$x_list=explode(",",$myArrayX); //explode string sent from flash
$y_list=explode(",",$myArrayY);

hl
July 7th, 2005, 05:57 PM
this is the basic jist of what i did (although mine was a bit different b/c i used a mysql db to store the x and y variables.
[AS]
// this is the movieclip AS //
// mc has instance name "dot" //
onClipEvent(load){
myArrayX = new Array(); // setup x array
myArrayY = new Array(); // setup y array
speed=5; // setup easing speed
}
onClipEvent(enterFrame){
i++;
myArrayX[i] = this._x;
myArrayY[i] = this._y;
this._x+=(_root._xmouse-this._x)/speed; // just making the mc follow the mouse
this._y+=(_root._ymouse-this._y)/speed;
}[/code]


// this is the buttom as to send the array //
on(release){
dot.loadVariables("array_php_test.php", "POST");
}


// php file is named array_php_test.php //
// flash sends the array as a string, so we explode it to put it back into an array //
global $myArrayX;
global $myArrayY;
$x_list=explode(",",$myArrayX); //explode string sent from flash
$y_list=explode(",",$myArrayY);

since it's being sent through post. instead of using global variables, wouldn't it be possible to use $x = $_POST['myArrayX']; and $y = $_POST['myArrayY'];