5 Replies Latest reply on May 16, 2007 8:14 AM by kglad

    Randomizer/Completed Series

    KelliBelli
      Here goes... I am trying to create a small game....

      Scene 3 - Frame1 exists to hold actionscript related to the rest of the code.

      In Frame2 I have a square grid covered by 49 small square buttons (7 across, 7 down)
      When a user clicks on any one of the instances of the button, flash randomly plays a frame selected from Frame3-Frame17. Currently, each of the frames in the random array contains a button that leads the user back to the first frame so that they can have another go....

      I would like to find a way to set it up so that...

      within the array of random frames, there are 2 "sub-arrays" if you will. I would like to script the button on the frames in each series to determine if all the frames in the "sub array" that the current frame belongs to have been played. If flash determines that all frames in the current "sub array" have not yet been played, the button would return them to the first frame of scene3. However , if it determines that all the "sub array" frames have indeed been played it would play a brand new frame to let them know they reached a conclusion, and in that frame would be a button that would return them to scene 1, thus allowing them to start over.

      Any assistance with this would be appreciated..

      Actionscript plugged into Frame1
      quote:

      var framesArray = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17];


      Actionscript on the button instances in Frame2
      quote:

      on (release) {
      if (framesArray.length != 1) {
      f = framesArray[j=random(framesArray.length+1)];
      framesArray.splice(j, 1);
      gotoAndStop(f);
      } else {
      gotoAndStop(framesArray[0]);
      trace("Last frame!");
      }
      }
        • 1. Re: Randomizer/Completed Series
          kglad Adobe Community Professional & MVP
          would you prefer to play the frames randomly WITHOUT repeats and then when all have played display your frame that lets the user know they reached the end and give them the option to return to scene1?
          • 2. Randomizer/Completed Series
            KelliBelli Level 1
            Well sort of, but it's more complicated than that.

            Basically, the grid of buttons found in Scene3/Frame2 contain script that directs the flash player to randomly play a frame selected from the array 3-17. This part of the code is working exactly as I want it to now.

            Currently, the button instances on each of those 15 frames all lead back to Scene3/Frame2. What I need to do is figure out how to script an if/else function on a subset of those buttons.
            Frames 3-7 are part of one group, and 8-17 are part of another group.
            For the buttons in frames 8-17, I need to figure out how to script an if/else function that asks if all of the frames in that group have been played. If any of those 10 frames HAVE NOT yet been played, the button will send the flash player back to Scene3/Frame2 so that the user can continue "playing". If all 10 frames HAVE been played, the button will direct the flash player to a new frame with a completion message and a button that points back to Scene1/Frame1

            • 3. Re: Randomizer/Completed Series
              kglad Adobe Community Professional & MVP
              that just seems screwy to me.

              chances are your users are going to require 30 or more frame views until they see all 15 frames. and it wouldn't be unusual for them to require 50 to 70 frame views until they see all 15 frames and can finally finish.
              • 4. Re: Randomizer/Completed Series
                KelliBelli Level 1
                The randomizer never selects the same frame twice, so I am not sure I see how they would need so many views to view all 15. Each time they view one, it is removed from the choices. Thus, if the user has viewed 3 frames, there will only be 12 left for the randomizer to choose from.
                • 5. Re: Randomizer/Completed Series
                  kglad Adobe Community Professional & MVP
                  then just run a test just before your gotoAndStop(f) statement to see if all the frames in f's group have been removed from framesArray.