javascript - How to pass an integer to create new variable name? -


i have 50 svg animations named animation0, animation1, animation2 etc. , want load them when integer 0 49 passed function:

function loadanimation(value){ var whichswiffy = "animation" + value; var stage = new swiffy.stage(document.getelementbyid('swiffycontainer'), whichswiffy); stage.start(); } 

it doesn't work @ moment, maybe it's passing 'whichswiffy' rather animation10?

any ideas?

if variables global,

var stage = new swiffy.stage(document.getelementbyid('swiffycontainer'), window[whichswiffy]); 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -