Dynamic variable name syntax
<p>Another newbie question that has me stuck badly.</p>

<p>I have three variables</p>

<pre><code>var state1
var state2
var state3
</code></pre>

<p>I need to access one of them on a .click event depending on a property of the clicked object.</p>

<p>How do I access the correct variable? Basically I need to for the variable name by adding "state" and the correct number together.</p>

<p>I will update this post soon with some code in case it's needed.</p>

<pre><code>var backstate1;
var backstate2;
var backstate3;
var currentFrame;

function hotspotHover(){
var currentElement = this;
var daName =this.name;
$("#hotspot" +daName).hover(

    function() { 
    $("img.changeOutline").prop("src", currentElement.outlinesArray[currentFrame]);
    $("#outlines").show(); 
    }, 
    function() { 
    $("#outlines").hide(); 
    }
).click(function() {
    var backstateLevelNumber = currentElement.backStateLevel; //not working
    window['backstate'+ backstateLevelNumber]=currentFrame; //trying to set backstate+number to current frame variable
    hoverClick(currentElement.defaultFrame);
    checkReverse();
    checkSeqLoop();
});

};
</code></pre>
