Saturday, 31 August 2013

javascript object declaration no working as i want it to

javascript object declaration no working as i want it to

i am creating a (lame) game, in which i declare the object player like so:
var player = {
"id": "player",
"displayText" : "<img src =
'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZSagpqJGExef2ebpgUWDH1dFVcyaJ-oFcIr-EUMYd8bHEUcDantAjIRzQrOoYqb1unJXQzykhjEBFsBFL42U87qgsIAC1QQMT-vc38EYXb8hVFZrBqcfmROMW8OTS7XaPdMm7ET8m1Ms/s1600/smileys_001_01.png'"
+
"class='onTop' id='" + this.id + "' alt='you' border='0' />" +
"<div id = '" + this.id + "health' class = 'healthLost hide'></div>",
};
however this.id is returning undefined, why and what can i do to fix this?

No comments:

Post a Comment