4 Replies Latest reply on Apr 12, 2010 9:59 PM by kglad

    Drawing program in Flash - How to...?

    Tukimoshi

      I have a small flash that I'd like to expand upon, and basically I'm wondering if it's possible to

      • Make a button that lets you erase things on click, rather than clearing the screen.
      • Draw lines of different colours/thickness
      • Have the Flash output a code for the drawing (similar to Punk-o-Matic 1/2) and be able to put it into the Flash in a text form to have it output the picture. (Thus allowing sharing of pictures).

      Here's the code.

       

      // 1. SETTING THINGS
      _root.createEmptyMovieClip("line",1);

      // 2. EVENTS IN _ROOT:
      _root.onMouseDown = function(){
      line.moveTo(_xmouse,_ymouse);
      line.lineStyle(2,0x000000,100);
      this.onMouseMove = function(){
        line.lineTo(_xmouse,_ymouse);
        updateAfterEvent();
      }
      }
      _root.onMouseUp = function(){
      this.onMouseMove = null;
      }

      Also see included .fla. It's very small as all it features is a default stage that you can draw on, with an Erase button that clears the screen.

      P.S: I don't completely understand the code, as I've found bits of pieces of what I want to do around the internet. I've tried figuring this out on my own, but

      I'm not too advanced in the field of ActionScript.

        • 1. Re: Drawing program in Flash - How to...?
          Tukimoshi Level 1

          Sorry for necro, but I have found no answer. Anyone have any idea how I could accomplish this?

          It would make for a cool flash-based drawing application, but I can't find out any way to accomplish separate line-styles other than possibly going to a different frame and pulling everything from the previous frame.

          • 2. Re: Drawing program in Flash - How to...?
            kglad Adobe Community Professional & MVP

            • Make a button that lets you erase things on click, rather than clearing the screen.
            • this is not easy and is difficult to implement
            • Draw lines of different colours/thickness
            • this is easy.  just do the obvious.
            • Have the Flash output a code for the drawing (similar to Punk-o-Matic 1/2) and be able to put it into the Flash in a text form to have it output the picture. (Thus allowing sharing of pictures).
            • this is tedious.

             

            1 person found this helpful
            • 3. Re: Drawing program in Flash - How to...?
              Tukimoshi Level 1

              Could I array the last 100 lineTo's atleast and have an undo button? That might be handy, but I'm not too sure how lineTo works exactly. It's an interesting function, and I already did the color/thickness settings, but I'm working on sliders for the RGB atm.

              • 4. Re: Drawing program in Flash - How to...?
                kglad Adobe Community Professional & MVP

                what you can do is create a different movieclip to apply each lineTo and keep an array of the movieclips.  that way you can remove the movieclips to erase a particular line segment.