5 Replies Latest reply on Mar 31, 2013 4:27 PM by xXZoloXx

    How to make a button generate a random word from a list

    xXZoloXx

      Hey guys

       

      I'm new at this so please use words I will understand.

       

      Here are two images I will be refering through without this post:

       

      1:

      XIdea.png

       

      2:

       

      XIdea 2.png

       

      So basically, when I click the generate buttonon the first image it takes you to the second image. What I want is when I click the generate button it comes to this screen, aswell as choose a random word from each list that I will make (Who List, What List, When List, Where List, and Why List) and place the word next to its position. When you click New Idea I want it to also generate another set of random words from the lists. How can I do this?

       

      Thanks

       

      Zolo

        • 1. Re: How to make a button generate a random word from a list
          Ned Murphy Adobe Community Professional & MVP

          To make a random selection from a list you first have to have the list.  An array makes a good list, so for each category create an array and fill each with whichever choices you intend.

           

          To randomly pick one of the items in the list you can use the Math methods that Actionscript is supported by.

           

          var whoList:Array = [1,2,3];

           

          var randomWho = whoList[Math.floor(Math.random()*whoList.length)];

           

           

          Please don't start new postings for the same topic

          1 person found this helpful
          • 2. Re: How to make a button generate a random word from a list
            xXZoloXx Level 1

            Ok so say:

             

            A small list of who is 1, 2, and 3

            A small list of what is 4, 5, and 6

            A small list of when is 7, 8, and 9

            A small list of where is 10, 11, 12

            And a small list og why is 13, 14, and 15

             

            Could you explain how I can put them into their arrays and where in the arrays I would put them and stuff like that?

             

            And would I have to have seperate buttons?

             

            And how could I make it display next to their designated areas

             

            Thanks

            • 4. Re: How to make a button generate a random word from a list
              robdillon Most Valuable Participant

              It sounds like you are very new to Flash. Which version of Flash are you using and which version of Actionscript are you using in Flash? Are you going to be using the timeline, or will you make everything in code?

               

              If you are working in the timeline, you will need to add a dynamic text field to the stage for each new word that you want to show. You can make all of the words show with one button, or one button for each word, that's a design choice that you make. I'm guessing that the "Back" button will remove all of the existing words.

               

              The arrays are variables and you can define them in an Actionscript window where you define the button function. As Ned showed you, you will also need to get a random word from each array. Once you have that word, you can put it into one of the dynamic text fields on the stage.

              1 person found this helpful
              • 5. Re: How to make a button generate a random word from a list
                xXZoloXx Level 1

                FLash CS6

                 

                Actionscript 3.0
                I am thinking code but which woud be easier?

                 

                I am very new so I didnt undrestand some of what you just said! So bare with me!

                 


                If I do use the timeline, are you saying I will have to make a new text box for each place I want the words?
                I would like al of the words to apear with one button
                The back button goes back to the title screen so yea I guess that is sort of what happens, gets rid of it in the process

                 

                 

                How would I do that and as I said in my reply above Bump, could you please show me an example with the numbers I gave you?
                How could I do that?

                 

                Thankyou!!!