Creating Images in Flash>Saving to Server>Creating Nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
elliotttt's picture

Hey everyone, I thought I'd post about a project I'm working on. My goal was to have a user create images in Flash, and ultimately have Drupal save the image on the webserver along with node data for retrieval later.

It works!

I'm new to using Services and AMFPHP, and to some extent Actionscript 3, but with the screencasts Rob Loach provided (HUGE thanks!!) I was able to start wrapping my head around this stuff. Even though the tutorials are done in Flex, with some fiddling I got it to work in Flash CS3.

I posted this on Drupal.org initially but I imagine it makes more sense to post here:

To accomplish this I needed an add-on class for Actionscript called JPEGExporter.as, part of a package called as3corelib which you can download here.

  • Install Drupal with Services, AMFPHP, and CCK
  • Create a new Actionscript 3 Flash Document
  • Grab the above mentioned as3corelib
  • In your AS3 application, you can get your image into a BitmapData object, which you can run through the JPEGEncoder class, and then stuff that into the new AS3 ByteArray Class.
  • AMFPHP supports ByteArrays, so you can send your ByteArray object off to a service you create in Drupal
  • The service captures the ByteArray, and can then write the jpg to the files folder, and give it a unique filename
  • The callback function which creates the JPEG can then return the value of the filename back to Flash again via AMFPHP
  • In your Flash application you can now give it the url to your files folder, plus a variable that contains the unique filename, and from here you can use another service to write all of the data into a new node
  • Of course you'll need a CCK textfield with the path to the image to do anything useful with the image, or you could get fancy and write it as an imagefield I suppose and use imagecache to further process your image

I know it's a brief summary but if you are familiar with services and AMFPHP this hopefully should make sense. I can't believe I was able to get this to work, and it works FAST too. The encoding is done in the swf too which might take a load off the server should the site get hit hard with traffic.

I'll try to post more info if anyone is interested.

Comments

so where is the site...

vyoumans's picture

I am interested in seeing it. Infact, I am about to do something kind of like what you are talking about.
v.

'Inflation is the one form of taxation not imposed by Legislation' - Milton Friedman
or...
'in an insane world, a sane man must appear insane' - spock

'Inflation is the one form of taxation not imposed by Legislation' - Milton Friedman
or...
'in an insane world, a sane man must appear insane' - spock

Hey elliotttt,

david.d.patrick's picture

Hey elliotttt,

I am interested in what you've done as currently I'm taking images in base64 sending it to Drupal and reading that same node with the base64. It works great but base64 is very data(space) intensive. This is an issue I'd like to over come, so please post more detail about your operations with saving images from AS3 to Drupal, thx

Drupal and Flex yeah!!!!

Drupal and Flex yeah!!!!

jpgEncode?

benthroop's picture

Hey David.d

What about jpeg encoding your image on the Flash side?

        public function jpgBitmapData(b:BitmapData):ByteArray
        {
            var jpegEncoder:JPEGEncoder = new JPEGEncoder(80);
            var imgData:ByteArray = jpegEncoder.encode(b);
            return imgData;             
        }

-Ben

More info please

thewolrus's picture

Like vyoumans, I would like to know more about your prpject, could you post some code?

Thanx

Yes I would love to see the

jjjames's picture

Yes I would love to see the AS3 code :) I want to create an Air app but having problems with permissions

You might be interested in

MattKelly's picture

You might be interested in seeing this:
http://www.largeanimal.com/cs/mustachr

The gallery uses images saved out by the Flash app (the app uses services/Drupal)


Large Animal Games | drupal.mattwkelly.com

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: