Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

BitmapExporter - generate PNG with specific filename

New Here ,
Mar 07, 2013 Mar 07, 2013

Hi All,

I am integrating Mario Klingemann's BitmapExporter into a small project and i have it so that the user can press a button and generate the png. Based on his comments in the code, I think that there may be a download dialog box/option that is supposed to pop up, but cant be sure about this. My problem is that i need some way for the user to get the file back after they generate it to the directory on my server. so far the code generates a uniqueID for each png. I was thinking that If i knew the specific file name that the user generates, then i would have more luck being able to somehow allow them to retrieve the file... Can anyone give me any insight as to what my best options might be?

The catch is that Mario's code also relies on PHP to generate the PNG, so my head is spinning a bit.

//some of the AS code:

private function onSaved( serviceUrl:String, fileName:String ):Void

                    {

                              BitmapExporter.dispatchEvent({

                                                                                                     type:             "saved",

                                                                                                     target:           BitmapExporter,

                                                                                                     url:              serviceUrl,

                                                                                                     fileName:                       fileName,

                                                                                                     uniqueID:                       uniqueID,

                                                                                                     sentBytes:                       sentBytes,

                                                                                                     time:                                 totaltimer,

                                                                                                     compressionRatio: sentBytes / (bitmapWidth * bitmapHeight * 4)

                                                                                                     });

                              reset( true );

                    }

//some of the PHP code which i believe helps generate the random number/unique ID:

case "getImageHandle":

                              $uniqueID = md5( microtime() . rand() );

                              sendResult( "success=1&uniqueID=$uniqueID" );

                    break;

Maybe i should be looking more in a PHP Forum, but I have always gotten my questions answered here, so wanted to try here first. Thank you in advance!

- Pat

TOPICS
ActionScript
683
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2013 Mar 07, 2013

fileName looks like the string you need to track down.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2013 Mar 07, 2013

Thanks KGLAD. I steered away from this variable because of the comment from the creator:


//  filename: The suffix of the filename automatically decides which output format you get, possible values are:

//  "yourfilename.jpg" or "yourfilename.jpeg" for JPEG format

//  "yourfilename.png" for PNG format

//  "yourfilename.bmp" for BMP format

He makes it sound like this is the file type doesnt he?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2013 Mar 07, 2013

yes, but you don't need (or want) to change the suffix.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2013 Mar 07, 2013

Thanks KGLAD. It was actually the PHP side that i was able to change:

$uniqueID = md5( microtime() . rand() );

I changed it to:


$uniqueID = ( "anyname" );

Problem is now that it only allows one file called "anyname.png" to exist in that directory.

Now i think i need to figure out through PHP how to add a number or something to each subsequently generated bitmap called "anyname.png" so that the user(s) do not overwrite the files. hmmmmmm



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2013 Mar 07, 2013
LATEST

you can use loadvars to send a variable (like the file name) from flash to your php file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines