3 Replies Latest reply on Aug 8, 2007 7:13 AM by kglad

    How do you make your own AS3 custom methods?

    Marcus_House Level 1
      I was wondering If I could make my own method for shape.
      I have written a little function to draw a line using a square brush from one point to another point.

      Now at the moment this is just a function as follows
      function drawSquareLine(shpe:Shape,x1,y1,x2,y2,brushWidth,color){
      with(shpe)
      {
      graphics.beginFill(0xFF0000,1);
      graphics.lineStyle(.25,0x000000,0);
      graphics.moveTo(x1,y1);
      graphics.lineTo(x2,y2);
      }
      }

      However I thought it would be cool if I could make it like a custom method (is that the right terminilogy?)
      So instead of supplying the shape as a param of the function.. could I make it be called like this?

      shpe.drawSquareLine(x1,y1,x2,y2,brushWidth,color);

      And if so could I have an example on how I would do this?

      cheers guys.