4 Replies Latest reply on Jan 8, 2016 6:30 AM by kglad

    Scope in html5 canvas

    moccamaximum Level 5

      with a movieclip "mc" on stage.

       

      Why does the following code fails ?

       

      //creating dynamic property works

      this.mc.position = 0;

       

      function clickHandler() {

          this.mc.position++;

          console.log("Position:" + this.mc.position);

         //shows Position:1

          updateMc();

          // Ende des benutzerdefinierten Codes

      }

       

      function updateMc(){

          console.log("Position:" + this.mc.position);

          //throws error cannot read property position of undefined

      }