9 Replies Latest reply on Apr 28, 2007 4:40 PM by evil_muffin_man

    Need help with game

    evil_muffin_man Level 1
      Since this project creates multiple questions, I am putting them all into this thread.

      Number 1: On the main storyline, I have a clip for the level. The level ccontains clips for the walls. How do I access the data from these walls (like x, y, width, height) with coordinates in relation to the main storyline.

      Number 2: Is there a replaceMovieClip? It would be handy because my character is contained in multiple movie clips.

      Number 3: The attached code does not go to the specified frame, nor does it trace "blah!"

      I will most likely have more problems later.
        • 1. Need help with game
          evil_muffin_man Level 1
          Also is the following statement legal for an If block?

          (((twallx - (twallw / 2)) < x < (twallx + (twallw / 2))) || ((twally - (twallh / 2)) < y < (twally + (twallh / 2))))
          • 2. Re: Need help with game
            kglad Adobe Community Professional & MVP
            1. level.wall1._x, level.wall1._width, etc

            2. no. you can use removieMovieclip and attachMovie() to replace a movieclip

            3. add your key listener: Key.addListener(_root)

            4. your if statement should not pass a syntax check. instead of using if(a < x <b), use if(a < x && x< b );
            • 3. Re: Need help with game
              evil_muffin_man Level 1
              For #1 I want dynamic acces (i.e. with a string for the insatnce name).

              I tested this separatly and parentClip["childClip"]._x works. However, twallx = lvl_mc["lvl" + game.level + "_" + "part" + i + "_mc"]._x; does not. I am very sure that the string it puts in is valid (game.level and i are numbers). I had it without the _mc but I changed that and yet it still shows up as "undefined." I tried it with and without _root.
              • 4. Re: Need help with game
                kglad Adobe Community Professional & MVP
                lvl_mc["lvl" + game.level + "_" + "part" + i + "_mc"]._x will work if you have, for example:

                game.level=1;
                i=2 and you have a movieclip with instance name

                lvl_mc.lvl1_part_2_mc

                use trace(game.level+" "+i+" "+lvl_mc["lvl" + game.level + "_" + "part" + i + "_mc"])

                and if you get 2 numbers and undefined, hard code the counterpart of

                lvl_mc.lvl1_part_2_mc (with the correct numbers)

                to see that this is an incorrect reference and not a syntax problem.
                • 5. Need help with game
                  evil_muffin_man Level 1
                  Amazingly, both tests passed. !BUT! I replaced the i's with a number. Maybe the i is being weird.

                  Also, the result of _x, _y etc. is being stored into a variable and the undefined came from the variable. Hmmm....

                  Also, this is being used in a for loop inside a function. The for loop initiates with i as 1 (this is the lowest "part" number).
                  • 6. Need help with game
                    evil_muffin_man Level 1
                    Okay, the function returns a value now (though I don't recall changing anything). It doesn't do the specified job, but for right now that's my problem.

                    There is a case where I use the attachMovie method with the brackets {} and it doesn't go where I want.

                    BAH! Why doesn't flash export for ActionScript automatically? I forgot to do that AGAIN...
                    • 7. Re: Need help with game
                      kglad Adobe Community Professional & MVP
                      if you prefix your variable with "var" inside a function, that variable will only be accessible inside the function. to remedy, remove the "var" prefix.
                      • 8. Re: Need help with game
                        evil_muffin_man Level 1
                        ARG! Foiled again.

                        Is there a way to make a conditional based on data type?

                        Like, if variable "foo" is a number, but was made a string, then it's NaN and the conditional returns either true or false. If it is a number it returns the opposite.
                        • 9. Need help with game
                          evil_muffin_man Level 1
                          Hulloooo?

                          I'm have problems acessing properties.

                          I have a crate class extending the movieclip class. It has an array property, Yet when I access it, it's undefined. The clip is an instance of a Crate which is set to the class. There is a boolean property that works. Is there anything I could be doing wrong?

                          I'm accessing the array with the syntax:

                          object.my_array[0] = "spee";