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 20100=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 1600060=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
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… ?
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.
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
awesome! thanks to both of you…
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).
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?
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