flash: why use "var"?

Out of context: Reply #10

  • Started
  • Last post
  • 13 Responses
  • subaddiction0

    It is used for local variables. put this in your timeline:
    test =function(){
    var testme="good"
    trace (testme);
    }
    test();
    trace (testme);

    and youll get:
    good
    undefined

    use this
    function test =function(){
    this.testme="good"
    trace (testme);
    }
    test();
    trace (testme)
    then you'll get
    good
    good

    And it would works just the name using:

    function test(){
    var testme="good"
    trace (testme);
    }
    test();
    trace (testme);

    or

    function test(){
    testme="good"
    trace (testme);
    }
    test();
    trace (testme);

View thread