Hi,
I have Image.js and Main.js files. I create image object like test = new Image(...);
and it can be seen on screen but when i try to do call Move method like
test.Move(x,y); it crashes. Is there anyway to do that?

My code :

main.js:

var objBall = new Image("abc.gif", 0, 0, visible);
objBall.Move(50,50);

image.js

function ImageDeneme(path, x, y, visible)
{
    this.image = document.createElement("img");
    this.image.src = path;
    document.body.appendChild(this.image);
    this.Move = Move;
    
    return this.image;
}

function Move(x, y)
{
    this.image.style.left = x + "px";
    this.image.style.top = y + "px";
}

waiting for your answers :)

i thing it should be like:

var objBall = new ImageDeneme("abc.gif", 0, 0, visible);

just use firebug to fine out what objBall. contains.

acctually i handle that problem and it works now but i have problem with inheritance now.

ImageClass.prototype = new Drawable(...);
ImageClass.constructor = ImageClass;

but i got "prototype is read-only" error. I'm working on a different platform but it supports javascript and as i got, it has different version of js.

could you tell how to inherit from a super class?

This article has been dead for over six months. Start a new discussion instead.