# How to draw simple triangles in existing script

**URL:** <https://forum.kirupa.com/t/how-to-draw-simple-triangles-in-existing-script/290138>\
**Category:** Uncategorized\
**Created:** [June 10, 2009, 7:44am UTC](https://forum.kirupa.com/t/how-to-draw-simple-triangles-in-existing-script/290138 "2009-06-10T07:44:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Centifolia](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Centifolia](https://forum.kirupa.com/u/Centifolia)\
**Post date:** [June 10, 2009, 7:44am UTC](https://forum.kirupa.com/t/how-to-draw-simple-triangles-in-existing-script/290138/1 "2009-06-10T07:44:25Z")

</div>

hi –  
I’m not that familiar with AS3 but I got a script from someone where some objects are drawn. I want to add several triangles so that each triangle can be dragged on the stage. Can anyone help how to do this in this script:

```auto
package app.simpleShapes {
 
    import flash.events.TUIO;// allows to connect to touchlib/tbeta
    import flash.events.TouchEvent;
    import flash.events.Event;// allows to connect to touchlib/tbeta
    import flash.display.*; 
    import flash.net.*;
    import flash.geom.*; 
 
    public class simpleShapes extends Sprite {
 
        private var num:Number=5; // number of rings to put
        //var ring:Ringx; //ring class (at bottom)
 
        public function simpleShapes():void {
 
            //--------connect to TUIO-----------------
            TUIO.init(this,'localhost',3000,'',true);
            trace("simpleShapes APP Initialized");
            //----------------------------------------
 
 
            // put "num" rings randomly on the stage
            for (var i:int = 0; i < num; i++) {
                objectR = new Ringx();
                objectR.x = Math.random() * 1024;
                objectR.y = Math.random() * 768;
                addChild(objectR);
   }
    
   // put "num" boxes randomly on the stage
            for (var j:int = 0; j < num; j++) {
                objectB = new Boxx();
                objectB.x = Math.random() * 1024;
                objectB.y = Math.random() * 768;
                addChild(objectB);
            }
        }
 
    }
}
 
import flash.display.Sprite; // ring class
import app.core.action.RotatableScalable;
 
class Ringx extends RotatableScalable {
 
    public function Ringx(thickness:Number = 10, radius:Number = 40, color:uint = 0xff0000) {
 
        //---RotatableScalable options------------
            //noScale = true;
            noRotate = true;    
            //noMove = true;
        //----------------------------------------
 
        graphics.lineStyle(thickness, color);
        graphics.drawCircle(0,0,radius);
 
        graphics.beginFill(0xffffff);
        graphics.drawCircle(0,0,radius);
        graphics.endFill();
    }
} 
import flash.display.Shape;
class Boxx extends RotatableScalable {
 
 public function Boxx(thickness:Number = 10, color:uint = 0xff0000) {
  
  //---RotatableScalable options------------
            //noScale = true;
            //noRotate = true;    
            //noMove = true;
        //----------------------------------------
 
        graphics.lineStyle(thickness, color);
        graphics.drawRect(0,0,100,100);
  
        graphics.beginFill(0xffffff);
  graphics.drawRect(0,0,100,100);
        graphics.endFill();
 
    }
} 

```

I tried to put the following code in the Ringx function but then the circle and triangle move at the same time.

```auto
var triangleHeight:uint = 100;
      graphics.lineStyle(1,0xff00ff00);
   graphics.beginFill(0xff0000);
    graphics.moveTo(triangleHeight/2, 5);
 graphics.lineTo(0, triangleHeight+5);
   graphics.lineTo(triangleHeight/2, 5);
  

```

Thanks for your help.
