title: Actionscript 2 call function from variable
body: <p>How can i call a function form a variable.</p>
  
  <pre><code>var upfunction = init;
  //or
  var upfunction = init();
  </code></pre>
  
  <p>I have tried the above code and it does not work. I want to be able to call that variable from a keypress and change the variables function. For example.</p>
  
  <pre><code>function init(){
     //Do whatever
  }
  
  function init2(){
     //Do another thing
  }
  
  var upfunction = init();
  if (Key.getCode() == Key.UP)
  {
      upfunction;
  } 
  </code></pre>
  
  <p>Then later doing </p>
  
  <pre><code>upfunction = init2();
  </code></pre>
  
  <p>That way i could change the function without having much code. Sorry if this is a noob question but all i do is copy and paste code i have found.</p>