2 Replies Latest reply on Oct 13, 2006 1:33 PM by trigger2160

    using the same code on another object

    trigger2160
      I am making a puzzle game in flash. to allow the user to win the game all of the puzzle pieces must be within the region of a grid. To make this work every piece requires 4000 lines of code (there probably is a simpler way, but at least it works). each puzzle contains a maximum of 8 pieces and there are 48 puzzles. i have so far only put this code on 16 pieces but flash has become slow and frequently crashes for no reason. if i put this code on every piece flash will probably not respond at all! these 4000 lines of code are the same for every piece so what i want to do is put these lines of code somewhere and then have each puzzle piece call these lines of code. i have tried using the function() but this won't work over different symbols. Is there any way i can put these lines of code only on 1 object and then call them on another object?
        • 1. Re: using the same code on another object
          Glazer Level 1
          It's fairly easy to re-use code for different movie clips, but i must say 4000 lines of code seems a bit much for a puzzle game.
          You might want to go back to the original code and streamline it a bit, before applying the code to anything else on the stage.

          Would it be possible for you to upload the .fla file and then link to it?
          • 2. Re: using the same code on another object
            trigger2160 Level 1
            here is the fla file.

            www.vectis-astro.org.uk/puzzle%20game%20stripped%20version.fla

            i need this much code because there isnt a definite answer to the puzzle. i could make a definite answer but then someone would find another answer. this method also shows if 2 pieces are overlapping. i have tried using a for loop but it doesnt work. this code does work and all i really want to do is write it once and then just link to it. do bear in mind i have stripped most of the game out to save on size.