6 Replies Latest reply on Nov 25, 2016 7:53 AM by P Steven

    HTML5 Canvas - Accessing variables across main timeline

    P Steven Level 1

      If I set a function or variable on the first frame of the main timeline I don't appear to be able to access them on later frames.


      So for example if on frame 1 I set the following variable:


      var rootRef = this;


      And the following function

      function test()
           alert ("test");


      If I try to refer to the variable rootRef on say frame 50, it is undefined


      And if I try to call the test function I get the following error:
      Uncaught ReferenceError: test is not defined(…)


      I would ideally like to include as much code as possible on frame 1 so any advice how to make variables and functions available across the timeline?