Hi guys,
there is a roughly Background object definition with 4 layers like:
Let's say I'd like to define an additional method to the object Background, which takes a layer and does something to it, i.e. add a picture to the layer.Code:function Background(){ this.layer1 = new Layer(1); this.layer2 = new Layer(2); this.layer3 = new Layer(3); this.layer4 = new Layer(4); } function Layer(number){ this.number = number; this.image = ''; // Image file name is empty for now, I'd like to fill it out appropriate later ... more misc stuff ... }
I've tried with following definition without success; FF25 did it, but IE10 crashes every time?!
Is there an error?!Code:function Background(){ this.layer1 = new Layer(1); this.layer2 = new Layer(2); this.layer3 = new Layer(3); this.layer4 = new Layer(4); this.addimage = function(layer){ layer.image = 'picture' + layer.number + '.jpg'; } } ... // ... and now I'd like to use my method var background = new Background(); background.addimage(background.layer1);



Reply With Quote

Bookmarks