面向对像的开发最主要的一个角色就是class ,但在FMS中,使用的是1.1的语法,因而在FMS端实现CLASS时需要一种特别的方式.例如
var ClassA = function(_p1,_p2) { var Pa1 = _p1; var Pa2 = _p2; this.GetPa1 = function() { return Pa1; } this.GetPa1Too = function() { return this.GetPa1; } this.Init = function() { //初始化 } //构造方法开始,构造方法的逻辑最好放在函数最后,因为如果要调用某些方法的时候,如果调用发生在定义之前,是会出错的 this.Init(); }
//使用时
var c1 = new ClassA(1,2); trace(c1.getPa1Too) // trace 1 |
阅读(355) | 评论(0) | 转发(0) |