-
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.
-
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.
-
Sooo nobody can help me out here.. going stir crazy with this one.
-
You have:
purity = int(pures / qnum * 100) + "%";
Have you tried:
purity = int((pures / qnum) * 100) + "%";
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|