Forum Discussion
Selecting random items from a list and displaying the selected items alone in order
With a short javascript, about 2 minutes. Without it about a million VERY carefully constructed triggers. I just cobbled this up off the top of my head, so when you try it, there may be some steps that are missing or need to be tweaked. The idea is that it starts at the bottom of the list of options that you have and if that item is chosen, puts it in the first spot of the final list. Then it moves up the list of potential choices, and when it gets to the top, the first spot in the final list contains the chosen item that is highest on the list of potential choices. It marks it so it won't be used again, and repeats the process for item two on the final list.
It would look like this:
On first slide, the potential choices are listed and named PotentialChoiceX where X = 1 – 10, and they each have a selected state. LastItemUsed is created as a number variable with a value of 0. When you have made all your selections, you continue to a layer, where the work is done with these triggers that fire when timeline starts:
1. Adjust variable ItemChosen1 Assign (text for PotentialChoice10) on condition PotentialChoice10 state is selected
2. Adjust variable LastItemUsed Assign 10 on condition PotentialChoice10 state is selected
Repeat triggers 1 and 2, changing the number in bold for numbers 10 – 1. The numbers must be in this order.
Adjust variable ItemChosen1 Assign (text for PotentialChoice9) on condition PotentialChoice9 state is selected
Adjust variable LastItemUsed Assign 9 on condition PotentialChoice9 state is selected
Once you have gone through triggers 1 and 2 for all the choosable items 1 – 10, the variable ItemChosen1 will contain the text for the selected choice with the lowest number; the top one chosen.
Now add these triggers so that choice will not be used again:
3. Change state of PotentialChoice10 Normal on Condition LastItemUsed = 10
Repeat trigger 3, changing the number in bold for numbers 10 – 1. The numbers must be in this order.
Change state of PotentialChoice9 Normal on Condition LastItemUsed = 9
Add this trigger to end the process when you use the item 10so you don’t have to go through all the triggers:
4. Jump to Next slide on condition LastItemUsed = 10
And there you have it. Repeat these 31 triggers (1, 2, and 3 for each of the 10 PotentialChoices, and 4 once at the end), changing the X in references to ItemChosenX from 1 to 10.
On the Next slide put ten Reference boxes, with the variables ItemChosenX, where X is 1 – 10, and when you jump there, they will be filled
Two hints to make it go faster
1. When you write the triggers for ItemChosen2, you do not need to include PotentialChoice1. If it had been selected, it would have been used for ItemChosen1. So each set of triggers will only need to check a decreasing amount of items, until you reach #10, which only has to check #10
2. There is the potential this could be easier to create if you create the triggers for ItemChosen1 on Layer1 and make the very last trigger show Layer2. Then Duplicate Layer1 to create Layer2. All the triggers will be copied over, and you just have change the references from ItemChosen1 to ItemChosen2. Try it, it may or may not be easier for you.
How could I do this with JavaScript? I'm in a very similar conundrum trying to select from 10 images in two rows, trying display the selected on in a single row on the next slide.