Drawing api drawing saving

ok - say i have made a swf where you can draw, with possible color change and different brush size, and i want to somehow save my drawing (in a database)
so i figured every little line that is drawn on enter frame has 6 values - start x, start y, end x, end y, color and size.
approximately - first 4 are 3 numbers, color is 6 numbers and size is 2 numbers length, so its 43+6+2=20 numbers for one little line
the framerate of the movie is 100fp/s so getting the maximum smoothness of the drawing, so one little line is drawn in 1/100 of a second, and in a second i have to save 20
100=2000 numbers.
a symbol is 8 bytes, so 20008=16000 bytes (/1024~15,5kb) - in a second!
so if you draw for a minute - its 16000
60=960’000 bytes (/1024~937,5kb~1mb) in a minute!

and my question is how to save a drawing to a database different way then im thinking, to me this seems the only way…

1mb per minute of drawing seems kinda lame for me and noone will want to wait till it loads up


…then i thought maybe i can zip it with php (…how?), but i dont think it is worth it…

The book Flash. Net shows how to do this with xml and ASP.net I am sure you could adapt it to php. but why would you want to do this? In the book example it is an online drawing application.

:x book… :x
i always have some problems with xml loading in flash - you have to write a pretty long script for just to be able to call the variables :-/ loadVariables and php is alot easier, could you give me a link where is how can i save drawings with xml… ?

i’m interested in saving API drawings as well. Anybody who can, please help

I have researched into saving a drawing made using the FLASH drawing API and haven’t come up with a good simple way, but am interested if anyone has info.
MY DRAWING APP at [url=“http://www.fndzinz.com/html/swfotw12.html”]http://www.fndzinz.com/html/swfotw12.html

What I did find out was that depending on the drawing complexity, there are several ways to get the drawing data out of FLASH and into a another setup in order to save it, basically reproducing the art in another language that has saving abilities.
Using SVG type drawing is shown at: http://www.w3.org/TR/SVG/paths.html using PATHS and at [url=“http://librsvg.sourceforge.net/docs/man-rsvg.php”]http://librsvg.sourceforge.net/docs/man-rsvg.php for some Unix server things, while in PHP it can be done with SVG [url=“http://www.zend.com/zend/trick/tricks12apr.php”]http://www.zend.com/zend/trick/tricks12apr.php
The MING library for PHP has info at: http://www.nyphp.org/content/presentations/GDintro/ , [url=“http://ca2.php.net/ming”]http://ca2.php.net/ming , [url=“”] ,
and a tutorial at: http://www.opaque.net/wiki/index.php?Tutorial

None of these are generally included in a default PHP install, so unless you have your own server are often out of availble setups.

Basically, you need to have a server tool, which recieves data from flash(xml) and redraws the ‘art’ where the file created can then be posted in a created HTML page , then allowing the user to download and save the output .jpg or whatever format; or it can be saved to a server file.

You can also save the drawing data to a localsaved object for local recreation, but a screen capture is the only way I’ve found to save the image then; as even if it is printed out, it will only create a printer type file.

Hope this helps

I have something I made a while back for this very thing I think. I’ll have to find it… I think it may need a little freshening up though (I dont think I completed it fully) - I’ll post an example when I find it and… well make one :wink:

awesome! thanks to both of you…:slight_smile:
senocular please find it…i’ve been looking for info for a long time…
i found voetsjobe* helping xMetal on this forum - they were saving it to an xml file and stuff… and that was great but they didn’t use colors/thickness etc. I’m trying to make mine with amfphp but i wish somebody helped me out with creating an array of the info to send to a db: in the end result i want users to be able to use different colors for their drawings and dif stroke thickness…anybody whose done something like this …please share
thanks again guys

ok, I found it. I think it works. I’ll make a little php example and post it when done (though there are some methods for it I never finished - I might write them up as well).

are you going through an xml file or straight to the db with remoting?

neither :stuck_out_tongue:

got me REAL interested now … can’t wait to see it, might save me loads of time
any chance you can hint on what you’re doing even before posting an example?

well its not nearly as impressive as anything mentioned above. Be prepared for disappointment. :crazy:

if it gets the job done then you got much further i did :slight_smile:

ok, well hold your horses, I still have to make a little drawing app. Gimme some time here :slight_smile:

thanks for doing this for us :slight_smile:

Remoting? Pffft. Databases? Who needs them!? And XML! If ever see another XML document I’m just going to scream!

What we have here is straight, good old-fasioned text. Thats right, a single string of characters to define your drawing. Using any server-side scripting language that allows you to save simple text files, you can take full advantage of this little app. This example was made in PHP:


The commands are pretty self explanatory… and if you hurry, you should be able to load in my little scene I just drew. Isn’t it perty? Since the same file is used for every instance of the web page, if anyone else were to save something else, any prior drawing would be erased.

Now I dont know how ship-shape this is, I just kinda whipped it up (it took me a little longer than expected :P) but there it is. The source files exist in that directory so just go up a level to check them out…


(just in case). Im going to try to clean up the fla a little to make it a little more comprehendable. The ASDRecorder class isnt commented at all… I probably won’t do that anytime soon (unless requested). Note: for the php file, see save_flash_drawing.php.txt

Anything like you were expecting?

oh yeah, btw, this was made in MX, not MX04, but, assuming there aren’t any case-typos, it should work fine there too (I’m assuming).

Hey Don’t bother Senocular
If you can use this project it is 141KB which is too big for an upload here
I’ll email it

Me? Don’t bother with what?