PDA

View Full Version : AMFPHP FlashToPHP Array for Printing in HTML


sam3k
06-19-2007, 09:14 PM
I build a Flash application that stores in LSO info input by the user but want to handle the printing in HTML since the print classes in Flash a rather limited.

Basically, I've been storing all the info in an Array similar to this:


var myArray:Array = new Array();
myArray[0] = {NAME:"Smith", TITLE:"Mr.", USAGE:true};
myArray[1] = {NAME:"Alba", TITLE:"Mrs.", USAGE:true};


For my purposes, I do not need to store into a database, just need to create an HTML page on the fly with the table layout ready for print.

I looked at the remotingBB tutorial but found it confusing since I do not know MySQL.

Now, I just learned that it is not possible to send Arrays to PHP using AMFPHP so I was wondering a few things:

1. Whats the best possible way to convert this Array to Object(s)

2. How to handle the php side so it creates an HTML page as soon the call is done from Flash.

3. Are there any tutorials on printing info received from Flash through AMFPHP.

sam3k
06-19-2007, 10:15 PM
Point One seems to work fine just by making this:

myObject = myArray;

I was able to return each individual object (from PHP to Flash) in the array like this:

function readFlashArray($in) {
$objValAbs = $in;
$temp = $objValAbs[1]['NAME'];
return array("theKey" => "Your Object contained the value $temp");
}


...based on talkback tutorial by Jesse Stratford

So hopefully that's taking care of.

All is missing is the creation of the actual table.

LOLFlash
06-20-2007, 12:06 AM
want to handle the printing in HTML since the print classes in Flash a rather limited.



Hi sam3k

1. I little lost your point, haw remoting helps you to do printing. You send an array to amfphp and return redesigned array.
I think you can do it directly in flash same result with less affords.

2. to create html use getURL with POST

3. The print class can do amazing things. A saw tutorial where movie for printing created out of stage so it is invisible on screen, duplicate all data what you need in this movie and print it. Take close look at addPage properties

sam3k
06-20-2007, 03:43 PM
I did use the print job class at first but found out that the print job has no way of knowing when to start printing the second page.

For instance, I build the table which was much longer than the page height so it printed all it was able to fit on the the first page and then stopped. You can make it print multiple pages of this first page but there doesnt seem to be a way of making it split the content over multiple pages.

So, thats why I want to just pass it to PHP (through an object or array) and build a HTML table in a for loop and call the print spooler.

sam3k
06-22-2007, 10:16 PM
The solution is to use a 'session variable.'

Basically, start a new session on the page where the main flash file is, then set the session variable on the PHP class and on return (in Flash) call the final page. On this last page, start session again and done!

It couldn't be any simpler!

Thanks to Patrick Mineault who suggested it.