0

I'm trying to create a new variable with the name of a passed in event, for example:

Say the passed in event

event.item.id

has the value "bg"

I then would like to create a variable named "bg" for which is to be a Bitmap using CreateJS.

I have tried various things, at the minute I have the following:

event.item.id = new createjs.Bitmap(img);

However when console logging the variable it comes up as undefined and I can't set anymore values to the variable such as x or y positions.

I hope this makes sense!

Martin
  • 176
  • 1
  • 14
  • 1
    This is explained over here pretty well: http://stackoverflow.com/questions/5117127/javascript-dynamic-variable-name – Perry Jun 07 '13 at 11:59
  • Thanks for that - I have followed those instructions however when I later try to do for example `bg.x = 200` I get the error `Cannot set property 'x' of undefined` – Martin Jun 07 '13 at 13:00
  • can you post your code in jsfiddle maybe? – olsn Jun 08 '13 at 13:16

0 Answers0