Skip to main content

Set variable within another context



I have the following function







"use strict";

function Player

{

this.width;

this.height;

this.framesA = 5;



this.image = new Image();

this.image.onload = function ()

{

width = this.width;

height = this.height / framesA;

}

this.image.src = "Images/angel.png";

}







How can I make this code to work?


I want the width and height in the Player function be inalized with the width and the height of the image when the onload function is called.





I need this to work with strict mode (A must).





If this should be accomplished another way feel free to teach.





EDIT: I updated the code to reflect a more realistic situation(I didn't know this will be so complicated)





EDIT 2: Another update to the code. I didn't notice that I wrote var insted of this. Sorry.





Thanks in advance


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?