Просмотр полной версии : Как задать метод объекту в конструкторе???
gOloVasTicK '~
28.11.2001, 22:29
function CScreen_getS(obj){
return obj.width*obj.height;
}
function CScreen (width, height) {
this.width = width;
this.height = height;
this.getS = CScreen_getS(this);
}
Не пашет :( Хелп плиз :(
а что именно должно работать?
gOloVasTicK '~
28.11.2001, 23:03
Ну я хочу что-бы getS был методом класса CScreen
То-бишь:
screen=new CScreen(10,10);
trace(screen.getS()); // 100
screen.width=5;
trace(screen.getS()); // 100 а надо 50
:(
[subway]design
28.11.2001, 23:03
function Obj(){
function Method(param1, param2){
...
...
...
}
}
//****************************************
//or maybe this :
//****************************************
function Obj.Method(param1, param2){
...
...
...
}
function CScreen (width, height) {
this.width = width;
this.height = height;
}
CScreen.prototype.getS = function() {
return this.width*this.height;
}
screen=new CScreen(10,10);
trace(screen.getS());
screen.width=5;
trace(screen.getS());
gOloVasTicK '~
28.11.2001, 23:29
Пасибо Иш :)
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.