3 Replies Latest reply on Jul 10, 2006 12:34 PM by corrodedlotus

    weird bug in static methods

      i keep getting this error when testing for syntax errors:

      The name of this class, 'Word', conflicts with the name of another class that was loaded, 'Word'.

      i already searched about this error in livedocs and most of them said that it's a time based error. So i checked and adjusted my time 1-2 days forward and back but it still showed.

      Then I tested again and I found out the culprit:

      I have two classes, named Word and Game. Game has a static method for shuffling arrays and the Word class calls it in one of its method(shown here):

      function shuffleWord() { ...
      ... }

      when I comment it out the class compiles fine. But when I don't BOTH classes complain with the above error(for the Game class, it complains about another Game class).

      can anyone shed light here? Why can't I call a static method from another class?

      If no one can answer the questions above, can anyoe suggest a better way of calling the shuffle(besides just putting it in both classes - it's kinda dirty and im a little bit OC lol) but if there's no 'elegant' fix for it then I'll just have to copy paste teh same method on both classes :(
        • 1. Re: weird bug in static methods
          blemmo Level 1
          I guess this is because in Game, it imports the class Word, and in Word, it imports the class Game, so what should be imported first? It's a circle...
          So you should rethink the design of your game. Maybe create a 3rd class with the static method(s), or have the method in Word and use it from Game. It's always good to have as few references to other classes as possible. I guess Game will need Word, but Word maybe doesn't need Game as well, so keep Word independent from Game and don't reference to Game there, if it's not totally necessary.

          • 2. Re: weird bug in static methods
            corrodedlotus Level 1
            hmm ill try making a 3rd class with static functions now :) thanks!
            • 3. Re: weird bug in static methods
              corrodedlotus Level 1
              actually it still errors when i save it but i think its a program bug already..right? it just has erros when i save it then test for errors. if i try to edit it then test for errors, it says everything is ok. when i save it, then test for errors, the rror shows up again.