无法通过as2中的原型向String类添加新函数
以下代码;
String.prototype.myFunction = function() { trace("my function is called"); };
var myString:String = "myString";
myString.myFunction();
使用 mtasc 编译器会导致此错误:
类型错误字符串没有字段 myFunction
必须可以通过原型向类添加新函数。
我可以做任何配置让 mtasc 能够编译此代码吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是在 myString 变量定义中指定类型信息。
在这种情况下它是可以编译并工作的:
problem was specifying type information at myString variable definition.
it is compilable and working in that case: