16 Replies Latest reply on Apr 22, 2008 9:01 PM by rlc5611

    hitTest doesn't work properly

    rockylhc Level 1
      I trying to do something that when a button clicked, then the clock needle starting to rotate, when it pointed to a number, the number will appear to some place, after that, the chess will move according to the number, but now I get stuck to the clock rotate part, can anyone please help?
      [URL=" http://www.mediafire.com/?mipoy2jpwmt"
        • 1. Re: hitTest doesn't work properly
          Gum Level 1
          Add this to the top of your code:

          var xpos = getProperty(chess, _x);

          Add this under your trace line of code:

          chess._x= (xpos + ((handnumber-1)*40));


          I am almost positive that there is a better way to do this, but this works.

          • 2. Re: hitTest doesn't work properly
            rockylhc Level 1
            i know there's smater way to do it, but this is all what i got. By the way, how can I add the step from the previous move of the step? And why the hitTest works weird like when it pointed to 2 and 5, it shows 3 and 6 respectively.
            • 3. Re: hitTest doesn't work properly
              Gum Level 1
              Is this what you want?

              http://www.mediafire.com/?embcdjb2ver

              I moved the chess thing to a MovieClip and I replaced the hitTest with rotation.
              • 4. Re: hitTest doesn't work properly
                rockylhc Level 1
                Thank for being helpful. Actually I'm planning to do something like Monopoly board game, the file you gave me working well, just that, I need to add up the step like, if first round it was 2, then the white "chess" walk two steps, and then, if the "clock" point to, let say 1, then it move forward one step.
                • 5. Re: hitTest doesn't work properly
                  rockylhc Level 1
                  Thank for being helpful. Actually I'm planning to do something like Monopoly board game, the file you gave me working well, just that, I need to add up the step like, if first round it was 2, then the white "chess" walk two steps, and then, if the "clock" point to, let say 1, then it move forward one step. I need it to show the 1st step and 2nd step, script like chess._x ++. Or anything can achieve it.
                  • 6. Re: hitTest doesn't work properly
                    rockylhc Level 1
                    Am I suppose to put Tween class to make it show the steps of the chess?
                    • 7. Re: hitTest doesn't work properly
                      rlc5611 Level 1
                      What does if (dunno=true) mean?

                      Oh and why run the onEnterFrame continuously when you only need it when the button is pressed? Set the onEnterFrame inside the randomBtn,onRelease handler and delete the onEnterFrame right after Chess2.gotoAndStop(handnumber);

                      I agree you don't need the hitTest at all and you could certainly clean up that group of ifs as you can calculate handnumber directly based on the angle using Math.floor().

                      Replace var rot = getProperty(hand, _rotation); with var rot = hand._rotation;

                      And I "dunno" what you are using dunno for. I can't see that it serves any purpose in either version of the fla. In addition to that, it is wrong logic.
                      • 8. Re: hitTest doesn't work properly
                        rlc5611 Level 1
                        This is more efficient as it will not continue running the onEnterFrame if the dial is not spinning.

                        I also noticed that the "hand" registration point is not in the center registration point of "roulette" which makes the result appear slightly off.
                        • 9. Re: hitTest doesn't work properly
                          rlc5611 Level 1
                          I added one more conditional to guarantee that you never land directly on the halfway point between two numbers.
                          • 10. Re: hitTest doesn't work properly
                            rockylhc Level 1
                            Thanks for your help. I put the "dunno" is because I'm afraid I have to add some action at that line , but now seems I don't it anymore, nice try for the delete this.onEnterFrame, but now the situation is that, what I intended to do here, is to treat the spinning thingy as a dice, after I roll it, then the chess will move to the place according the number, but where I get stuck is the showing steps part, and the steps add up from the previous.

                            http://www.mediafire.com/?9gmx41fml4x
                            • 11. Re: hitTest doesn't work properly
                              rlc5611 Level 1
                              Having the onEnterFrame continue to run when the wheel is not spinning serves no useful purpose whatsoever and uses resources needlessly. You are already starting off with your white spot on the first square. The attached script considers that by initializing where_am_i to 1. This still deletes the onEnterFrame and will step you along your movieclip.

                              I realized that you need to also check to see if you have reached the end of your chess2 clip. If you do not check to see if the current frame has reached the total frames, the interval won't clear so I have added that to the conditional.
                              • 12. Re: hitTest doesn't work properly
                                rlc5611 Level 1
                                I don't know if you want to do this or not but I was playing with your movie and realized I could continually spin the wheel while the spot was moving. This has the potential to cause a problem. This attached script is the same as before except that the button is temporarily disabled until the spot has finished moving.
                                • 13. Re: hitTest doesn't work properly
                                  rlc5611 Level 1
                                  I was looking at your chess2 and you can use this strategy of stepping through a movieclip for a single player game. If you plan to use a multiplayer game, that strategy won't work.

                                  Make another copy of your FLA file and delete the chess2 movieclip entirely and try the attached script instead of what you currently have. I set it up for four players just to test.
                                  • 14. Re: hitTest doesn't work properly
                                    rlc5611 Level 1
                                    And for what it's worth, here is the four player version written entirely in actionscript so you don't need anything on the stage.

                                    This is now over the top.
                                    • 15. Re: hitTest doesn't work properly
                                      rockylhc Level 1
                                      man, your are awesome! Thank you very much!
                                      • 16. Re: hitTest doesn't work properly
                                        rlc5611 Level 1
                                        Last post I promise but this is just way too much fun. I got some ideas yesterday so thought I would post them. BTW I can't take too much credit. Almost all this script is copied right out of the Flash help files. Now if I could just find a way to script Vanna White to spin that wheel......Hmmmm.......

                                        Last edit too......