A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Purity Test, Problem getting a percentage at the end.

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147

    Purity Test, Problem getting a percentage at the end.

    Hey there.. i'm currently building a purity test and am having a problem with get the percentage a the end, it either 0 or some crazy number.. trying to work out what's wrong with my coding.. i've tried using the math round format, but that doesn't seem to produce nothing..

    So i'm wondering if any of you knew what my bug is.?

    Andy.



    Code:
    function convertMyAnswers()
    {
        var _loc1 = _root;
        for (i = 0; i < 67; i++)
        {
            _loc1["answer" + i] = myAnswers[i];
            converted = false;
        } // end of for
        converted = true;
    } // End of the function
    function yes()
    {
        myAnswers.push("yes");
        if (qnum < 66)
        {
            if (yeses[arrayNum] == 1)
            {
                pures = pures + 1;
    			trace("this is pures.." + pures);
            }
            else
            {
                sins = sins + 1;
    			trace("this is sins.." + sins);
    			
            } // end else if
    		
    		
            qtext = questions[qnum];
    		//var purity:Number = Math.round((pures() /qnum() * 100 + "%");
    														
    		purity = int(pures / qnum *360) + "%";
    		trace ("this is the question number" + qnum );
    		trace("this is how pure you are..." + purity);
            arrayNum = arrayNum + 1;
            qnum = qnum + 1;
        }
        else
        {
            if (yeses[arrayNum] == 1)
            {
                pures = pures + 1;
            }
            else
            {
                sins = sins + 1;
            } // end else if
            convertMyAnswers();
            if (converted == true)
            {
                gotoAndStop("end");
            } // end if
        } // end else if
    } // End of the function
    function no()
    {
        myAnswers.push("no");
        if (qnum < 66)
        {
            if (nos[arrayNum] == 1)
            {
                pures = pures + 1;
    			trace("this is sins.." + pures);
            }
            else
            {
                sins = sins + 1;
    			trace("this is sins.." + sins);
    			
            } // end else if
            qtext = questions[qnum];
            purity = int(pures / qnum * 100) + "%";
            arrayNum = arrayNum + 1;
            qnum = qnum + 1;
        }
        else
        {
            if (nos[arrayNum] == 1)
            {
                pures = pures + 1;
            }
            else
            {
                sins = sins + 1;
            } // end else if
            convertMyAnswers();
            if (converted == true)
            {
                gotoAndStop("end");
            } // end if
        } // end else if
    } // End of the function
    qnum = 1;
    arrayNum = 0;
    qtext = questions[arrayNum];
    converted = false;
    stop ();

    Much thanks in advance.

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147

    ok well.. [UPDATE]

    Having tried a few more things ... i'm now convinced i have to rewrite this function.. as it seems to be busted somewhere..

    my only other thought is that it's deviding by one rather than the number of items in the array. but i could be wrong.

    Andy.

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    Sooo nobody can help me out here.. going stir crazy with this one.

  4. #4
    Senior Member
    Join Date
    May 2004
    Location
    East Yorkshire, England
    Posts
    423
    You have:
    purity = int(pures / qnum * 100) + "%";

    Have you tried:
    purity = int((pures / qnum) * 100) + "%";
    Feeling chatty?
    http://www.mitsuku.com

  5. #5
    Senior Member
    Join Date
    Nov 2004
    Location
    I'm a brumie, currently in London working for the man
    Posts
    147
    tried that still no luck it's no good.. think there must be something wrong with a var somewhere. i'm not sure.

    Andy.

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