I want to create a paint tool in flash like a tool in microsoft windows, help me plz
rajarajan2017
MidiMagic 579 Nearly a Senior Poster
I don't think you understand how enormous such an undertaking is. I once wrote a paint program back in the early 1980s. It took a year, and just as I finished it, the computer it was written for was discontinued.
JasonHippy 739 Practically a Master Poster
I wouldn't say it's impossible to do, but it depends on how complex you want to make the app.
Using Flashdevelop and AS3, I recently made a simple flash app to put onto my active desktop at work so I can leave TODO notes on my desktop, or aimlessly doodle while waiting for long debug builds to finish...I've set up the flash file to be the same colour as a real post-it note, and set it up so that certain keys change the pen colour and size, clear the drawing area or restore the original pen colour/size settings. The whole thing uses the standard drawing API and took less than 30 minutes to throw together.
To do it was just a case of creating a main class for the flash file, initialising the drawing area and setting-up the initial pen size and colour using a call to graphics.linestyle.
Then set up some listeners and handlers for keyboard events(KEY_DOWN) and mouse events (MOUSE_DOWN and MOUSE_UP).
In the MOUSE_DOWN event handler, make a call to graphics.moveto to move the graphics cursor to the mouse cursor position and set up a listener for the MOUSE_MOVE event and a handler to do the drawing. Then in the MOUSE_UP remove the MOUSE_MOVE listener..
In your handlers for keyboard events, you check the keypresses and call whatever functionality you've created for that key (i.e. change pen size, or pen colour using graphics.linestyle)...
Once you've got that working, you can gradually extend it to include other tools, but they would be a little more involved.
Adding a pallette would be simple to do, you'd just create buttons on the stage and attach handlers for mouse events which call the desired functionality...
Tools to create circles/polygons/rectangles, again would be a little bit more involved, but shouldn't be too difficult as the flash graphics API contains functions to draw basic shapes like rectangles and circles! If you want to add rubberbanding to the shapes (whilst positioning and sizing them) then again, it's another level of complexity, but not impossible!
Like I said, my recent app only used the standard drawing API, but there would be nothing to stop you from using the Bitmapdata and Bitmap classes to push the drawing data into, but if you wanted to save the drawing out to an external file, that could prove to be a more complicated problem, what with all of the flash security/sandbox stuff to deal with!
Jas.
rajarajan2017
Thanks Jas, But I have the knowledge of that graphic linestyles and know how to draw line and curves in flash. but when coming to built a application it becomes complicated. do you have any tool which was completed?
JasonHippy 739 Practically a Master Poster
Thanks Jas, But I have the knowledge of that graphic linestyles and know how to draw line and curves in flash. but when coming to built a application it becomes complicated. do you have any tool which was completed?
Hey Raja.
No, I don't have a fully featured paint-clone, but I do have a very very simple little post-it note application; as described in my original post.
You've already said you know your way around the drawing API, so there is nothing to stop you from creating a simple tool like my post-it note app and extending it to include more and more advanced functionality... As long as you have a good object oriented design methodology you should be able to put something together in no time!
As previously mentioned, the only REAL difficulty is going to be if you want users to be able to save or print their pictures from flash...Then it's a completely different ball-game!
I've never had to do anything with regard to printing anything from flash, so I don't know much about it. But I do know that to export image data from flash, the bitmap data (in text format) would have to be passed/streamed to a php script (or perhaps a javascript!).
The script then needs to convert the passed text data into a .bmp or .png image on the server, which your script would finally allow the user to download and save.... I'd assume that similar steps would have to be undertaken to print images too!
Cheers for now,
Jas.
rajarajan2017
Thanks Jas,
As you said, the difficult portion is about to save and print which was drawn.
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.