views:

16

answers:

1

following code;

String.prototype.myFunction = function() { trace("my function is called"); };
var myString:String = "myString";
myString.myFunction();

causes this error with mtasc compiler:

type error String has no field myFunction

it must be possible to add new functions to a class via prototype.

is there any configuration i can do for mtasc to be able to compile this code?

A: 

problem was specifying type information at myString variable definition.

it is compilable and working in that case:

String.prototype.myFunction = function() { trace("my function is called"); };
var myString = "myString";
myString.myFunction();
ekesken