A method assigned to a variable can be invoked via that variable using the standard parentheses operator, ( ). : function variable « Function « Flash / Flex / ActionScript






A method assigned to a variable can be invoked via that variable using the standard parentheses operator, ( ).

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

    var consume = eat;
    consume();


    }
    public function eat () {
      trace("eat");
    }    
  }
}

        








Related examples in the same category

1.Function type variable
2.Referencing Functions
3.Creating Anonymous Functions
4.Bound Methods, which is treated as a value