Frame Random Shuffle without repeating

Hi,
Am beginning an eLearning project (I'm a retired social worker aiming in this lesson to help others) which includes building in AS3 an exercise called the GNAT (Go No/Go Association Task). The GNAT is a test tool that measures people's subconscious attiudes by having them choose (or not choose) by  pressing/touching the spacebar (in this lesson) when they see a specific target word.
For the first part of the GNAT, a practice exercise: 16 target words (presented one each in its own frame), taken randomly with no repeats from a list or array of 18 words. Frame needs to time out in 1000 ms. If the person reacts by pressing/touching the spacebar when they see a word, it is either scored +1 (depends on the word) or nothing. If pressed, an X or 0 displays for 100 ms (wrong or correct, depending on the word) and then goes immediately to the next random (no repeat) frame and word. If not pressed the timer timeout at 1000 ms goes to the next random (no repeat) frame.
Whew! For my relatively modest AS3 skills, not sure how to set up a model for this and implement in script. Could also be one dynamic text box in a single frame instead of multiple frames, with the text (target word) changing. But still would need a timer to advance and if pressed, an over-ride of the timer to advance, plus scoring.
If I can get a basic model working, then I can try to build the main test exercise tool which has 9 target words but these are recycled randomly in a 3:6:3 ratio totaling 70.
Major challenge!!!
I've tried various random no repeats using frames but can't get the most basic version to work.
I would appreciate any help getting started. How best to set this up and begin?
Regards,
saratogacoach

Using frames is not likely to be relevant to what you seem to want to do.  One frame, one textfield, and code is all you should need.
Just create the array, shuffle it, and pick the first 16 or whatever words in the shuffled array, one at a time as you advance thru the exercise.  If you want a function to shuffle the array you can find the same one often offered in this forum, such as here...
http://forums.adobe.com/thread/1058786?tstart=0
If you need help with setting up a Timer, you should not have a problem searching Google for a tutorial (use "AS3 Timer tutorial")

Similar Messages

  • 6 random numbers without repeat

    I'm trying to make a 6 digit random number generator between 1 and 48. When the user click a button 6 random numbers show up in 6 different textFeilds. The problem is that I don't want the same number twice. How can I generate 6 different random numbers without using return and breaking out of the function?
    import flash.events.Event;
    stop();
    btn.addEventListener (MouseEvent.CLICK, random1);
    function random1 (evt:Event) {
              display1.text = "";
              display2.text = "";
              display3.text = "";
              display4.text = "";
              display5.text = "";
              display6.text = "";
              var r1 = Math.floor(Math.random()*(1+48-1))+1;
              var r2 = Math.floor(Math.random()*(1+48-1))+1;
              var r3 = Math.floor(Math.random()*(1+48-1))+1;
              var r4 = Math.floor(Math.random()*(1+48-1))+1;
              var r5 = Math.floor(Math.random()*(1+48-1))+1;
              var r6 = Math.floor(Math.random()*(1+48-1))+1;
              if (r2 == r1 || r3 == r2 || r4 == r3 || r5 == r4 || r6 == r5) {
                        return;
              var liste:Array = new Array();
              liste.push(r1,r2,r3,r4,r5,r6);
              liste.sort(Array.NUMERIC);
              display1.text = String(liste[0]);
              display2.text = String(liste[1]);
              display3.text = String(liste[2]);
              display4.text = String(liste[3]);
              display5.text = String(liste[4]);
              display6.text = String(liste[5]);

    Here's the code for the approach mentioned with your textfields included
    btn.addEventListener (MouseEvent.CLICK, random1);
    function random1 (evt:Event) {
        var nums:Array = new Array();
        // fill the array of numbers
        for(var i:uint=1; i<=48; i++){
            nums.push(i);
        shuffle(nums);
        // grab the first six in the shuffled array
        var liste:Array = nums.splice(0,6);
        // assign the values to the textfields
        for(var j:uint=1; j<=6; j++){
            this["display"+String(j)].text = String(liste[j]);
    function shuffle(a:Array) {
        var p:int;
        var t:*;
        var ivar:int;
        for (ivar = a.length-1; ivar>=0; ivar--) {
            p=Math.floor((ivar+1)*Math.random());
            t = a[ivar];
            a[ivar] = a[p];
            a[p] = t;

  • Random Generation without repeat

    Hi, I am trying to write a script that will generate a random 5 digit number, using only the digits 1, 2, 3, 4, & 5, and with no repeats. For example: 12345, or 31524, or 24153. At the moment I can make the random 5 digit number, using only the digits 1, 2, 3, 4, & 5, yet I am struggling to get no repeats. So far I have something along the lines of:
    set x to some item of "12345"
    set y to some item of "12345"
    set z to some item of "12345"
    set a to some item of "12345"
    set b to some item of "12345"
    if x = y then
    if x ≤ 1 then
    set x to x + 1
    end if
    if x ≥ 5 then
    set x to x - 1
    end if
    else if x = z then
    if x ≤ 1 then
    set x to x + 1
    end if
    if x ≥ 5 then
    set x to x - 1
    end if
    else if x = a then
    if x ≤ 1 then
    set x to x + 1
    end if
    if x ≥ 5 then
    set x to x - 1
    end if
    else if x = b then
    if x ≤ 1 then
    set x to x + 1
    end if
    if x ≥ 5 then
    set x to x - 1
    end if
    else
    set itemsOne to x & y & z & a & b
    end if
    set itemsOne to x & y & z & a & b
    itemsOne
    Any Ideas??
    Thanks for any help you can give,
    MrBlobE

    Hello
    In addition to what others have said.
    This sort of script could be done efficiently by class filtering of index list.
    The basic is this :
    {1, 2, false, 4, false}'s integers --> {1, 2, 4}
    {1, 2, false, 4, false}'s some integer --> {1, 2, 4}'s some item --> 2, e.g.
    Thus you might try something like this :
    --set nn to {1, 2, 3, 4, 5}
    set nn to "12345"
    return some_permutation(nn)
    on some_permutation(aa)
    script o
    property xx : aa -- source list
    property yy : {} -- result list
    property kk : {} -- index list
    repeat with k from 1 to count my xx
    set end of kk to k
    end repeat
    repeat (count my kk) times
    set k to my kk's some integer -- some integer (class filter)
    set my kk's item k to false -- suppress the chosen index
    set end of my yy to my xx's item k -- extract item by chosen index
    end repeat
    if my xx's class = list then
    return my yy's contents
    else
    return "" & my yy
    end if
    end script
    tell o to run
    end some_permutation
    Regards,
    H

  • Randomize/shuffle array item without repeat actionscript 3.0

    i am creating a question and answer quiz using flash cs3 and actionscript 3.0.
    i have a large array of question, i wish to put it into xml document
    (can xml document be reside in the flash file itself?i thought ive seen someone did that.)
    ok,my main problem is to shuffle the questions without repeat until all questions were asked. i have worked on this tutorial,and it does great shuffling without repeat. http://www.flashandmath.com/howtos/deal/
    but,i wish to ask one question at once. i have looked into the option to shuffle frames, but i think about how can i count the score of the quiz at the end of it?
    can anyone tell me the best way of doing this?
    many thanks 

    . i have looked into the option to shuffle frames,
    you can`t really shuffle frames in flash, you have to tell the playhead of your movie to jumpp to a specific frame.
    so if you have say 20 Questions that are ordered in 20 kjeyframes along the main Timeline. you will have an array o Numbers from 1-20 that is shuffled by a function like you mentioned above.
    Then in the function that evaluates your answers that targets this aray as a pointer to where to go next.
    The pointer could be a simple Number, that describes the position of one specific number in this array, like so:
    //At the beginning of your quiz
    var randArray:Array = [1...20];
    var pointer:int = 0;
    var points:int = 0;
    var right:Boolean= false;
    //in the function that evaluates your answer
    function evaluateAnswer():void{
       if(right){
       points+=1;
    else{
    //don`t add Points
    //this will choose the next frame from your shuffled Array
    pointer++;
    if(pointer<=20){
    this.gotoAndPlay(randArray[pointer]);
    else{
    //when the last question is answered do something in a funtion that shows the result
    showResult();

  • How do I generate random numbers from a list of numbers without repeating any number

    I am trying to generate a list of random numbers without any repeating numbers.  For example say the list is from 1 to 15, how do I randomly generate a list of numbers using each number only once?

    pb,
    You can build a randomizer by making a 2-column table with 15 rows. In Column A, Fill with the numbers 1 to 15. In column B Fill with RAND(). Then sort on Column B. There will now be a randomized list of the numbers from 1 to 15 in Column A. You can copy this random list and use it in your application.
    Jerry

  • How can i return to a playlist i stopped without repeating songs already played

    If i am listening to a playlist in shuffle mode, then stop it and play something else, is there a way to return to the playlist and resume it without repeating songs previously played?

    Changing versions often does not cure problems, but it does increase risks.
    * ( Do Not ) [[Install an older version of Firefox]]
    The search options will not be changed by downgrading, but there is a method of changing that without downgrading.
    * See Ed's [/questions/1044599#answer-685295]
    I am not sure the changes in Firefox 35.0.1 would cause your audio issues
    * https://www.mozilla.org/en-US/firefox/35.0.1/releasenotes/
    The first step in troubleshooting that may be to identify the tab or page involved, then try Firefox with only the newtab page and the problem page open.
    IIRC Firefox is intended to continue streaming audio even if a tab does not have focus. That enables users to stream audio in the background whilst browsing. What you hear may be intended behaviour.

  • Random shuffling

    Today my iPod started shuffling tracks within a playlist. It shuffles music and audiobooks. The setting is not on shuffle so I'm not sure where this random shuffling is coming from. Any ideas? Help?

    So the Shuffle setting that is accessible via the Now Playing screen is white (meaning it is off).  The Shuffle icon looks like to arrows crossing over each other and can accessed by tapping the Now Playing screen once, which also brings up the repeat icon/setting and scrubber bar.
    B-rock

  • Creative Zen 8GB Random Shuffle

    Creative Zen 8GB Random Shufflej I have owned a Creative Zen V Plus 4GB for two years and have really enjoyed it. About a month ago, the screen started to fade out and is now totally black. I have researched this problem and have come to the realization that there is no way to fix the issue short of either shipping my player in for repairs or buying a new Zen V Plus. I have tried all the "fixes" I could find on here and other places. Nothing works and a lot of others seem to have the same issues with their players. The player still plays fine, but with no screen, it is very?tough to use correctly. I am willing to "start over" with a new player and am interested in the Creative Zen 8GB. The player looks real nice and has all the features I need. I read online that the Creative Zen 8GB DOES NOT have a random shuffle feature. I was just wondering if this is true? I love setting my player on random shuffle and letting it randomly choose the songs. If this is not a feature on the Zen, I guess I wouldn't be interested in buying one. Does anyone know if the Creative Zen 8GB has the random shuffle feature?

    Yes it does. You would from the music menu scroll to DJ & choose random play all

  • I want to add new songs to my ipod.  When I set it up with itunes years ago I had a different computer that I no longer have.  Now it will not let me add new songs to my ipod shuffle without erasing everything that is already on it.  Help!!!

    I want to add new songs to my ipod.  When I set it up with itunes years ago I had a different computer that I no longer have.  Now it will not let me add new songs to my ipod shuffle without erasing everything that is already on it.  Help!!!  Is there any way around this?

    Yes, I was aware of this but the phrase "Any items imported from audio CDs or acquired from other sources will not copy from your device to the iTunes library." is what worries me.  Will this eliminate my Notes, Calendar Events, etc or will it apply mostly just to the music?

  • Random shuffle no longer works

    I have itunes installed on my pc.  Random shuffle feature no longer works. Latest version on itunes is installed.

    Shuffle mode displays songs in the wrong order when you have the song number field selected in the first column.  My iTunes displays a shuffled playlist in the order in which songs are added to library, not in the playlist order for shuffle mode.
    Songs are not in the order in which they will play, shown above.  They are in Date Added order in shuffle mode with song number selected as the sort order in iTunes.  This IS an iTunes problem.  Not an issue in iTunes 10 or previous.

  • How to replace a sub vi that is used in many main VIs with another sub vi under a different file name without repeating the replace vi operation?

    Hello,
    I am converting a LV5.1.1 llb to LV7.1 that contains serial sub VIs ("Serial Port Read.vi", "Serial Port Write.vi", and "Bytes at Serial Port.vi") that need to be replaced with the newer VISA serial sub VIs ("VISA Read.vi", "VISA Write.vi", and "VISA Bytes at Serial Port.vi").  The older serial sub VIs are used on many different main VIs under the same llb, and I want to be able to replace all the older serial sub VIs with the equivalent VISA sub VIs in LV7.1 without repeating the same replace VI task on each main VI.  Please advise if it can be done in LV7.1 and how?
    Thank you so much for your help,
    Valen

    If you have the old serial VIs in the llb, make a copy of it and delete them. Then, when you open the top level VI in 7.1, LabVIEW should replace them with compatibility VIs of the same name but using VISA.

  • Random numbers without duplicates

    Hello,
    I'm having trouble locating an explained example for selecting a set of random numbers without duplicates. Specifically, I'm working on this example from Ivor Horton's Beginning Java, chapter 3.
    3. A lottery program requires that you select six different numbers from the integers 1-49. Write a program to do this for you and generate five sets of entries.
    This is not homework, I'm just trying to teach myself Java to eventually work my way up to servlets and JSPs.
    This is what I have so far. I tried to use array sorting but it didn't work (the first three numbers in my entries was always 0), so I commented out that part. I've included sample output after the code. I don't necessarily need the exact code although that would be nice; I just need at least an explanation of how to go about making sure that if a number has been picked for an entry, not to pick it again.
    Thanks for any help,
    javahombre
    package model;
    import java.util.Random;
    import java.lang.Math.*;
    import java.util.Arrays;
    public class Lottery {
    public static void main(String[] args) {
    // Lottery example.
    // We need the following data:
    // - An integer to store the lottery number range (in this case 59).
    // - A mechanism to choose a number randomly from the range.
    // - An array to store the entries (6 different numbers per entry).
    // - A loop to generate 5 sets of entries.
    int numberRange = 59;
    int currentPick = 0;
    int[] entry = new int[6]; // For storing entries.
    //int slot = -1; // For searching entry array.
    Random rn = new Random();
    for (int n = 0; n < 5; n++)
    // Generate entry.
    for (int i = 0; i < 6; i++)
    currentPick = 1 + Math.abs(rn.nextInt()) % numberRange;
    //Arrays.sort(entry);
    //slot = Arrays.binarySearch(entry, currentPick);
    //System.out.println("i: " + i + "\t| slot: " + slot + "\t| pick: " + currentPick + "\t| compare: " + (slot < 0));
    // Add the current pick if it is not already in the entry.
    //if (slot < 0)
    entry[i] = currentPick;
    System.out.println("pick entered: " + currentPick);
    // Output entry.
    System.out.print("Entry " + (n + 1) + ": ");
    for (int j = 0; j < 6; j++)
    System.out.print(entry[j] + "\t");
    System.out.println("");
    // Set the array contents back to 0 for next entry.
    Arrays.fill(entry,0);
    Sample output (notice duplicates, as in Entry 3):
    pick entered: 11
    pick entered: 29
    pick entered: 33
    pick entered: 8
    pick entered: 14
    pick entered: 54
    Entry 1: 11     29     33     8     14     54     
    pick entered: 51
    pick entered: 46
    pick entered: 25
    pick entered: 30
    pick entered: 44
    pick entered: 22
    Entry 2: 51     46     25     30     44     22     
    pick entered: 49
    pick entered: 39
    pick entered: 9
    pick entered: 6
    pick entered: 46
    pick entered: 46
    Entry 3: 49     39     9     6     46     46     
    pick entered: 23
    pick entered: 26
    pick entered: 2
    pick entered: 21
    pick entered: 51
    pick entered: 32
    Entry 4: 23     26     2     21     51     32     
    pick entered: 27
    pick entered: 48
    pick entered: 19
    pick entered: 10
    pick entered: 8
    pick entered: 18
    Entry 5: 27     48     19     10     8     18     

    NOTE: the array reference to [ i ] seems to be misinterpreted as italics by the posting form. I've reposted the message here, hopefully it will show the code properly.
    Thanks again,
    javahombre
    Hello,
    I'm having trouble locating an explained example for
    selecting a set of random numbers without duplicates.
    Specifically, I'm working on this example from Ivor
    Horton's Beginning Java, chapter 3.
    3. A lottery program requires that you select six
    different numbers from the integers 1-49. Write a
    program to do this for you and generate five sets of
    entries.
    This is not homework, I'm just trying to teach myself
    Java to eventually work my way up to servlets and
    JSPs.
    This is what I have so far. I tried to use array
    sorting but it didn't work (the first three numbers in
    my entries was always 0), so I commented out that
    part. I've included sample output after the code. I
    don't necessarily need the exact code although that
    would be nice; I just need at least an explanation of
    how to go about making sure that if a number has been
    picked for an entry, not to pick it again.
    Thanks for any help,
    javahombre
    package model;
    import java.util.Random;
    import java.lang.Math.*;
    import java.util.Arrays;
    public class Lottery {
    public static void main(String[] args) {
    // Lottery example.
    // We need the following data:
    // - An integer to store the lottery number range (in
    this case 59).
    // - A mechanism to choose a number randomly from the
    range.
    // - An array to store the entries (6 different
    numbers per entry).
    // - A loop to generate 5 sets of entries.
    int numberRange = 59;
    int currentPick = 0;
    int[] entry = new int[6]; // For storing entries.
    //int slot = -1; // For searching entry
    array.
    Random rn = new Random();
    for (int n = 0; n < 5; n++)
    // Generate entry.
    for (int i = 0; i < 6; i++)
    currentPick = 1 + Math.abs(rn.nextInt()) %
    numberRange;
    //Arrays.sort(entry);
    //slot = Arrays.binarySearch(entry, currentPick);
    //System.out.println("i: " + i + "\t| slot: " + slot +
    "\t| pick: " + currentPick + "\t| compare: " + (slot <
    0));
    // Add the current pick if it is not already in the
    entry.
    //if (slot < 0)
    entry[ i ] = currentPick;
    System.out.println("pick entered: " + currentPick);
    // Output entry.
    System.out.print("Entry " + (n + 1) + ": ");
    for (int j = 0; j < 6; j++)
    System.out.print(entry[j] + "\t");
    System.out.println("");
    // Set the array contents back to 0 for next entry.
    Arrays.fill(entry,0);
    Sample output (notice duplicates, as in Entry 3):
    pick entered: 11
    pick entered: 29
    pick entered: 33
    pick entered: 8
    pick entered: 14
    pick entered: 54
    Entry 1: 11     29     33     8     14     54
    pick entered: 51
    pick entered: 46
    pick entered: 25
    pick entered: 30
    pick entered: 44
    pick entered: 22
    Entry 2: 51     46     25     30     44     22
    pick entered: 49
    pick entered: 39
    pick entered: 9
    pick entered: 6
    pick entered: 46
    pick entered: 46
    Entry 3: 49     39     9     6     46     46
    pick entered: 23
    pick entered: 26
    pick entered: 2
    pick entered: 21
    pick entered: 51
    pick entered: 32
    Entry 4: 23     26     2     21     51     32
    pick entered: 27
    pick entered: 48
    pick entered: 19
    pick entered: 10
    pick entered: 8
    pick entered: 18
    Entry 5: 27     48     19     10     8     18

  • How do i make a frame a enclosing a repeating frame appear only on the last page of a report?

    I have a frame that encloses a repeating frame. How so i make them print only on the last page?

    Assuming you have other content, you could:
    set the Print Object On property to be last page.
    anchor it to the main content that repeats on every page, so this frame only prints after the other one is done
    Assign a format trigger where you make it display only if current page is equal to total number of pages
    create a trailer and move the frame there

  • How can i transfer iPhone 3G photo to iPhoto without repeating the same photo to iPhoto?

    How can i transfer iPhone 3G photo to iPhoto without repeating the same photo to iPhoto?

    Sorry, you question doesn't make sense. If you're trying to import photos, in your camera roll, to iPhoto, iPhoto doesn't import them twice.

  • The new appearance of the Notes App is really disappointing. I used it for lists and now it just makes my notes appear to be random paragraphs without visual separation.  Am I missing anyway to customize the App?

    The new appearance of the Notes App is really disappointing. I used it for lists and now it just makes my notes appear to be random paragraphs without visual separation.  Am I missing anyway to customize the App?

    No, you can't customize it.  Try different apps available in the App Store.

Maybe you are looking for