# Custom Operators

**URL:** https://forum.kirupa.com/t/custom-operators/167766
**Category:** flash
**Created:** [October 31, 2005, 8:45pm UTC](https://forum.kirupa.com/t/custom-operators/167766 "2005-10-31T20:45:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![decumbo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/decumbo/32/1890_2.png) [@decumbo](https://forum.kirupa.com/u/decumbo)
#### Post date: [October 31, 2005, 8:45pm UTC](https://forum.kirupa.com/t/custom-operators/167766/1 "2005-10-31T20:45:38Z")

</div>

I was wondering if there was a way to make custom operators in Flash. I’m trying to make a function that will add the x and y coordinates of two vectors.

va=[x1,y1]  
vb=[x2,y2]  
vc=va+vb=[x1+x2,y1+y2]

```auto
function Vector(x, y)
{
    this.x = x;
    this.y = y;
}

Vector.prototype.plus = function(v2)
{ 
    this.x += v2.x; 
    this.y += v2.y;
}

var green=0x00CC00;
var black=0x000000;
var thickness=.5;

//Draws a line from vector a to vector b
function DrawLine(va,vb)
{
    var Line:MovieClip = this.createEmptyMovieClip("Line",getNextHighestDepth());
    Line.lineStyle(thickness,colour,100);
    Line.moveTo(va.x,va.y);
    Line.lineTo(vb.x,vb.y);
}

var va = new Vector(10,40);
var vb = new Vector(60,60);
var vc = new Vector(60,60);
vc.plus(va); // i would rather be able to use vc=va+vb;

trace("va=("+va.x+","+va.y+")");
trace("vb=("+vb.x+","+vb.y+")");
trace("vc=("+vc.x+","+vc.y+")");

var colour = black;
DrawLine(va,vb);

var colour = green;
DrawLine(vb,vc);

```

Once I figure this out I’ll make a vector manipulation class and I can continue with my work.

Any help would be much appreciated!
