num and genderconstant are working as integers, but the formula isn't working. I defined var drinks = 0; and var hours = 0; on another page. Any thoughts as to why this code isn't working?
import flash.events.MouseEvent;
mornshots_btn.addEventListener(MouseEvent.CLICK, takeShots);
function takeShots(event:MouseEvent):void
{
drinks++;
trace(drinks);
mornshots.text = String(drinks);
}
hours = hours+4;
var BAC1 = (drinks * 0.06 * 100 * 1.055 / num * genderconstant - 0.015 * hours);
q1_btn.addEventListener(MouseEvent.CLICK, traceBAC1);
function traceBAC1(event:MouseEvent):void
{
trace(BAC1)
}
mornshots.text = String(drinks);
Try tracing each of the variables in that line to see which one(s) are not numerically defined. If any happen to come from textfields, then you need to be sure to convert the values from text to numbers before trying to process them.
Also, unless there are other circumstance around that code, that line of code you show in red will only execute once at the beginning of testing since it is not inside any function. So whatever value you trace for it will not change even if values that would define it change later on.
All of the variables are working, but now the answer is always -.06, no matter what the weight input is (num = weight).
The formula I have is BAC1 =((drinks * 0.06 * 100 * (1.055/num) * genderconstant) - (0.015 * hours));
It's different than the original, but there's still the same problem.
Gender constant depends on the person's gender. .66 for female and .73 for male.
North America
Europe, Middle East and Africa
Asia Pacific