# Adding function to math object

**URL:** <https://forum.kirupa.com/t/adding-function-to-math-object/95177>\
**Category:** Uncategorized\
**Created:** [November 21, 2003, 5:25pm UTC](https://forum.kirupa.com/t/adding-function-to-math-object/95177 "2003-11-21T17:25:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bongbox](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@bongbox](https://forum.kirupa.com/u/bongbox)\
**Post date:** [November 21, 2003, 5:25pm UTC](https://forum.kirupa.com/t/adding-function-to-math-object/95177/1 "2003-11-21T17:25:44Z")

</div>

i have this functions and i want to add to math object but i get this errors

[FONT=times new roman][SIZE=1]FUNCTION[/SIZE][/FONT]  
[COLOR=red]  
[COLOR=blue]  
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

- 

```
       Distance function *

```

_**/  
[/COLOR]  
Math.prototype.distance = function (x1,y1,x2,y2) {  
var dx=x2-x1;  
var dy=y2-y1;  
return Math.sqrt(dxdx+dydy);  
};  
[COLOR=blue]  
/**_\*\*

- 

```
      Radians to Degrees *

```

**_/  
[/COLOR]  
Math.prototype.radToDeg = function (angle) {  
return angle_(180/Math.PI);  
};  
[COLOR=blue]  
/**

- 

```
 SINE FUNCTION = HEIGHT (_y) *

```

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*_/  
[/COLOR]  
Math.prototype.sinD = function (angle) {  
return Math.sin(angle_(Math.PI/180));  
};[/COLOR]

[FONT=arial][SIZE=1]ERROR[/SIZE][/FONT]  
[COLOR=red]  
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: There is no method with the name ‘radToDeg’.  
trace(Math.radToDeg(Math.PI));  
[/COLOR]  
Total ActionScript Errors: 1 Reported Errors: 1
