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();

Similar Messages

  • Submit multiple item without "Repeating table"

    Hi
    How can I do submit multiple item in list with single infopath form without repeating table?

    Create a workflow and create items with what ever information you want.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

  • Using a "shuffle" function to randomize an array?

    Hi, for some reason when the line of code "koan.shuffle();" is commented out swfs called "koan_1.swf" or "koan_2.swf" etc are loaded properly into a "koan_loader_mc" on the stage, albeit not randomized.  (Each "koan_#.swf" has code in its last frame to both advance the "shuffle" array in the action script in the first frame of the stage and to load the next koan swf.)   Why does "koan.shuffle();" not only fail to randomize the array, but, break the entire loading process? 
    Frame on main stage:
    // creates function called at the end of koan_#.swfs
    function shuffle(a:Array) {
    for (var ivar = a.length-1; ivar>=0; ivar--) {
    var p = Math.floor(Math.random())(ivar+1);
    var t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    This code loads swfs (but they are not randomized/shuffled):
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    //koan.shuffle();
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thanks (this is a clarified question from a previous post now marked as answered)

    because shuffle() is a function, not an array method:
    // creates function called at the end of koan_#.swfs
    function shuffle(a:Array) {
    for (var ivar = a.length-1; ivar>=0; ivar--) {
    var p = Math.floor(Math.random())(ivar+1);
    var t = a[ivar];
    a[ivar] = a[p];
    a[p] = t;
    This code loads swfs (but they are not randomized/shuffled):
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    shuffle(koan);
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thanks (this is a clarified question from a previous post now marked as answered)

  • 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")

  • 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.

  • 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;

  • Error While creating a regular item without any demo data.

    Hi All,
    In RMS13.1.1, during creation of an item without any demo data, and entering all the required inputs on the item master & itemsupp form. When we click on “Retail by Zone” the following error message got displayed “Exchange rates does not exist” on the Item Retail Price by Zone window form.
    Thanks,
    Sushanth.D
    Edited by: user10680684 on Jul 13, 2010 2:51 AM

    What you can do is open the Form's fmb code in Forms Developer IDE, or switch on session level or database level SQL_TRACE to see the SQL statements that the Form is firing to the database. (Find the tracefile in the udump folder). Replaying the SQL statements from the SQL trace file in e.g. SQL*Developer may lead to a cursor or block that e.g. does not return any rows. You may need to replace bind variables' placeholders (:a1 etc.) found in the trace file with the relevant business values for your items, zones, etc.
    Good luck and let us know how you progress,
    Erik Ykema

  • G/L account item without tax code in document with deferred taxes

    Hi ,
    While releasing the billing document to accounting i get this error " G/L account item without tax code in document with deferred taxes". Not able to release it to accounts. What could be the possible reason??
    Actually, this error is occuring only when i am using a Discount Condition (Z Condition).
    Please guide what could be the problem in the Discount Condition?
    Thanks and Best Regards

    whats this Z condition type. Is it  a tax condition type. If yes , please check the tax code assigned to this in the condition type defintion (VK12) and in FTXP check if this code is assigned with Account key.
    Also in the pricing procedure, if this condition is Active (not statistical) whats the account key assigned to it. Then check  whats the GL Account assigned to this Account key (VKOA).
    Then in FS03 , check this GL account number and under "Control Data" whats the Tax category maintained. You can have a * for the tax category here.
    Hope this helps
    Regards
    Sai

  • How to convert a open item become cleared item without using F-32

    Dear experts,
    Can I convert an open item become clear item without using F-32.
    Please help.

    Hi,
    You can use F-28.
    If it's useful assign points
    Thanks&Regards,
    Kumar

  • Returning a ZERO on Slow-Moving Item without transaction

    Hi all,
    Via a multi-provider, we have implemented several slow-moving item in our reports, eg we return all the value of some dimensions whether we have transaction or not on these dimension values.
    Now for dimension value for which we have no transaction it returns in Bex an empty result on the key figure instead of a zero, is there a way to force BW to put a zero on a slow-moving item without any transaction?
    Thanks in advance for your assistance
    David

    Hallo
    FI you go to the Query Designery --> Property Display than you can cusotmioze how to display the zero. You probably have the option Zero Values Display as Blank.
    I hope this can help you
    Mike

  • Is there a way to keep the checkmark or initials (Sign toolbar) active so that I can check a whole list of items without going back and forth to the button?

    Is there a way to keep the checkmark or initials (Sign toolbar) active so that I can check a whole list of items without going back and forth to the button?

    There is another way to "popup" the screen. Mute and then
    unmute the cellphone.
    Sheng-Chieh

  • 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.

  • Purchasing info records for PO-items without material master

    Hi gurus,
    I would like to have the system automatically determine certain settings (e.g. reminder/urging data).
    For PO-items with material master there is no problem, because all information can be stored in the purchasing info record, and are automatically found when I enter the material number.
    For items without material number/master I tried to generate a info record for the material group. When I enter the no. of the info record, everything works fine. But the info record is not automatically found, if I only enter the material group no.
    Is there any way to make the system find the info record by itself?
    Thanks
    Alicia

    Thanks to both of you!
    Priyanka:
    How can you create a source list for a material group? I thought this was possible for materials only!?
    Of course, you cannot have more than one info record at a time for a material group. But one would be enough for me...
    Dhruba:
    Thanks for the advice, but I know how to manually select a info record. The point is, I'd like to have the system determine it according to the material group I enter.
    Any other ideas?
    Alicia

  • Sort open items without +/- sign

    Hi SAP Experts,
    i would like to display the open items without +/- sign when i will try to sort. it is possible in edit options in while clearing. but when i will try to display the open items i can not get that option. i have tried with t.code - fb00, htere is option for open items, but that is not working out.
    Please suggest solution for my problem as early as possible.
    your assistance will be highly appreciated.
    Regards,
    suresh konisetty.

    Suresh,
    Not possible w/o +/- sorting.

  • No delivery expediter for PO item without material master

    Hello gurus,
    when I create a PO with an item without material master (just user-defined text), my system does not create a delivery expediter in ME91F, although the delivery is overdue. When I use a material master in the item, the expediter is created just fine.
    Does anyone have an idea what could be wrong here?
    Thanks
    Alicia

    Hi,
    Check in ME22N, under "Delivery" Tab whether following is maintained
    Reminder 1
    Reminder 2
    Reminder 3
    If not then maintain ad if you want it to come automatically in PO then check in SPRO > MM > Purchasing > Material Master > Entry Aids for Items Without a Material Master > Here assign the Purchasing Value Key to the material group
    It will start picking it for this material group for Text PO also.

Maybe you are looking for

  • Want to get PSE organiser 11 to recognise duplicates at import

    I have recently acquired a macbook pro with mountain lion and bought photoshop elements because I am familiar with the windows version (older). (I want to keep the photos i download in folders i can see, not embedded in iPhoto). The first batch of ph

  • Get data for current month in VC from query - Urgent

    Hi all, I have designed a query for cube FIAR_C03 for overdue items and query output contains customer, net due date, document date, fiscal year period and amount. I want a chart for that query in VC that only contains those items in which net due da

  • Drop down menu in CSS

    After someone suggested the P7 link ( http://www.projectseven.com/tutorials/navigation/auto_hide/index.htm[i ), I was able to reverse engineer it and figure out how it works (obviously not a feat of genius, but I'm new at this). Anyway, I got it work

  • Sap api query

    Hi everybody, Can anyone explain me what is  sap api query? Please help. Thanks Sonali

  • What is different?  setProperty works, c:set does not ???

    I have a class that I am instantiating twice (separate instances... i.e. using different scopes) in a jsp page. In the second instance I tried to set three properties using c:set, target, and property. It gave me an error saying the last property did