0 Replies Latest reply on Jul 11, 2007 8:51 AM by Rothrock

    Static Class Function vs. Instance Variables

    Rothrock Level 5
      I'm making a Wheel class to spin the wheels on some toy trains as they move back and forth.

      Each wheel on the train is an instance of the Wheel class and there are several of them.

      I thought it would be great to just have a static class function to tell all the Wheels to start turning:


      The Wheel class keeps a static array of all of its instances so I thought I would just loop through all of those instances and issue the wheelInstance.roll() method.

      So far it all works. But I was planning to use a setInterval to call the roll() method and each instance has its own rollID property that I would like to assign the setInterval ID to. Here is the problem.

      Since the rollID is an instance property I can't access them from a static class function. Is there any way to do this? Currently I"m just using an onEnterFrame which doesn't require me to use the instance properties.