4 Replies Latest reply on May 31, 2011 9:50 PM by A.kameshwaran

    line with a arrow

    A.kameshwaran Level 1

      Hi All,

           I want to draw multiple line with a arrow.  Please guide me how can i do it by code dynamically. exactly as below.

       

       

      Regards,

      Kameshwaran A.

        • 1. Re: line with a arrow
          LukeElChul Level 1

          create an empty symbol

           

          put this code in it.

           

           

           

           

           

          //***** Set some opening parameters

           

          onClipEvent (load) {

           

          //Make original line invisible

           

          _root.line._visible = 0;

           

          //Initiate some variables

           

          number_lines = 0;

           

          line_active = 0;

           

          }

           

          //***** Every time the mouse button is released...

           

          onClipEvent (mouseUp) {

           

          //Get the position of the mouse

           

          origin_x = _xmouse;

           

          origin_y = _ymouse;

           

          //Increase the number of lines by one

           

          number_lines++;

           

          //Generate a new line name

           

          name = "line"+number_lines;

           

          //Duplicate a new line

           

          _root.line.duplicateMovieClip(name, number_lines);

           

          //Position the line's end point at mouse position

           

          _root[name]._x = origin_x;

           

          _root[name]._y = origin_y;

           

          //Update line length / orientation

           

          _root[name]._xscale = _root._xmouse-origin_x;

           

          _root[name]._yscale = _root._ymouse-origin_y;

           

          //If this is the start of a new shape

           

          if (!line_active)

           

          {

           

          //Set the line tracking variable

           

          line_active = 1;

           

          //Set the start point of the new shape

           

          start_x = origin_x;

           

          start_y = origin_y;

           

          }

           

          }

           

          //***** Every time the mouse is moved

           

          onClipEvent (mouseMove) {

           

          //If there's a line currently being drawn...

           

          if (line_active)

           

          {

           

          //Update line length / orientation

           

          _root[name]._xscale = _root._xmouse-origin_x;

           

          _root[name]._yscale = _root._ymouse-origin_y;

           

          updateAfterEvent();

           

          }

           

          }

           

          //***** When a key is pressed

           

          onClipEvent (enterFrame) {

           

          //If it's the Enter key

           

          if (Key.isDown(Key.ENTER))

           

          {

           

          //Join the end point of this line...

           

          //...to the start point of the first line in this shape

           

          _root[name]._xscale = "";

           

          _root[name]._yscale = "";

           

          //Reset line-tracking variable

           

          line_active = 0;

           

          }

           

          }

           

           

          draw a line convert it to a symbol and give it an instance name of line.

           

          and there you can draw lines.

           

           

           

          detach the lines by pressing enter.

           

          and thats it.

           

           

           

          your welcome in advance (:

           

           

           

          INPORTANT to leave all your symbols in the scene not in the libery are it will not work

           

          Message was edited by: xFARRELLx

          • 2. Re: line with a arrow
            A.kameshwaran Level 1

            Hi,

                  Thanks for the reply. What i need is a line with arrow and should not be attached from the library. It should be drawn in runtime on demand.

             

             

            Is it possible to draw like this dynamically in run time.line.JPG

            • 3. Re: line with a arrow
              LukeElChul Level 1

              so you whant the line to just draw by itself.

               

              you whant an arrow go in the sybol line and draw an arrow.

              • 4. Re: line with a arrow
                A.kameshwaran Level 1

                I will be having x and y points. With that i will be drawing the line. Now i need to add arrow inorder to show the line flowing direction. give some idea for me.