dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 33 of 33

Thread: post for ram_son

  1. #21
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    hmm .. i ran the file and output the array (arr) before it was shuffled.
    i then ran 10 questions (after shuffling) and compared their position against the original array.
    the output appears quite random -

    Century, arr[98]
    Abortive, arr[3]
    Celestial, arr[97]
    To achieve, arr[20]
    Bourgeois, arr[76]
    To bypass, arr[84]
    Adversary, arr[29]
    To account for, arr[16]
    Abundant, arr[9]
    Access, arr[12]

  2. #22
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PS .. it should not matter to the array random function as to how many
    elements there are in the array.
    an example is, which is basically what we are doing in the file -
    PHP Code:
    arr = [];

    for(var 
    n=0;n!=100;n++){
    arr.push(n);
    }

    trace("before shuffle"+newline+arr);

    arr.sort(function(){return Math.floor(Math.random()*3)-1}); // shuffle

    trace("after shuffle"+newline+arr); 
    typical output is -
    PHP Code:
    before shuffle
    0
    ,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99

    after shuffle
    97
    ,32,35,15,1,19,82,64,90,42,41,66,33,13,2,20,62,24,25,3,27,0,99,38,39,22,67,16,93,61,26,17,12,14,43,31,45,94,28,37,21,79,78,89,40,65,48,47,87,76,71,11,57,53,74,70,63,36,77,73,29,6,9,58,44,56,8,18,68,72,34,80,83,49,85,54,81,91,96,5,7,69,30,55,52,4,59,95,92,75,88,46,98,10,50,84,23,60,51,86 
    Last edited by a_modified_dog; 10-16-2009 at 12:05 PM.

  3. #23
    Member
    Join Date
    Aug 2009
    Posts
    44
    Never mind a_modified _dog... I screwed something up in the fla where the randArray was not working right. I tested it with the complete db and it seems to be working fine. Thanks a lot again. Your help is very much appreciated. I will try to get the range choice buttons work . I'll come back to either ask for more help or to close the thread.

  4. #24
    Member
    Join Date
    Aug 2009
    Posts
    44
    I tried to follow your suggestion and come up with an If statement that will allow the user to choose a particular section of the db but could not make it work. What I came up with is that if in the load function I set n=100 and the arr.length to 200 like this:
    for(var n=100;n!=200;n++){
    then the "nextBtn" button will pick only from this section of the xml.So I thought about having a welcome page to the quiz that includes buttons assigned to different parts of the db like group one, group two, and so on. This way the user clicks on the buttons that takes him to the section he wants to be tested in. Is this like a primitive way of doing things or is it OK? I still need help on the click label event where it informs the user if the answer he chose was correct or not and to keep track of the score as a percentage.
    Accomplishing these two tasks will complete the project for me.

  5. #25
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    set a frame variable -- score=0;
    we already use -- correctAnsw = arr[id].theSynonym;

    so psuedo code on the "click label event " ?? --
    if(userchoice == correctAnsw) score+=1;

    at the end of the quiz section (100 questions ?? ) scoreTxt.text = score+"%";

  6. #26
    Member
    Join Date
    Aug 2009
    Posts
    44
    I was thinking of having the percentage score shown all the time and updated continuously with every question.

    What do you think of the solution for selecting certain sections of the xml file ? Do you think it's ok to use?

  7. #27
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    there are very little in the way of set rules in Flash.
    Actionscript language often allows multiple methods of achieving the same result.

    what is important is that it is bug free, reliable and CPU friendly

  8. #28
    Member
    Join Date
    Aug 2009
    Posts
    44
    I cannot get the feedback and score texts working right yet. What I did so far is create an AnswerButton button symbol and put four of the instances over the answers text labels. Under the "on release" for each button I put the following:
    on (release) {
    if(userchoice == correctAnsw)
    feedbackTxt.text = ("Correct");
    else
    feedbackTxt.text = ("Sorry");
    scoreTxt.text = score+"%";
    }
    What I get is one instance of displaying "Sorry" in the feedbackTxt and nothing else. The labels do not respond to further clicks and the score text doesn't change. I know I must be doing something wrong but I still can't figure it out.

  9. #29
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    where/how are you defining userchoice ?

    in my example userchoice was psuedo code

  10. #30
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i have attached a fla for you that encompasses score and button selection

    i have not tackled the selection of sections of the xml file
    Attached Files Attached Files

  11. #31
    Member
    Join Date
    Aug 2009
    Posts
    44
    I added this in frame 1 action code:
    checkuserchoice = function(userchoice){
    if (userchoicer==CorrectAnswerNumber)
    feedbackTxt.text = ("Correct");
    else
    feedbackTxt.text = ("Sorry");
    scoreTxt.text = score+"%";
    }

  12. #32
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    see my last post

  13. #33
    Member
    Join Date
    Aug 2009
    Posts
    44
    Sorry, didn't see your last post...I must have been posting at the same time. Anyways you did it again!!! Great work.. I really hope you get as much enjoyment out of helping newbies like me who feel great when they see the ideas they have in mind working smoothly... especially after being frustrated so frequently in the process. Thanks a million again.. and I hope you don't mind me saying I know where to come if I need help with Flash ansd Action Script.
    Helpful and patient people like make this forum a great one.

    Don't see how to mark this thread resolved!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center