Copy link to clipboard
Copied
I'm working on a Blood Alcohol Calculator for a class project. The user will be able to input their weight and gender. They will be able to select how many drinks they have at different points in a day. At the end of the game, they will get a list of their BAC at each point in the game as well as their overall BAC. I'm running into trouble with the formula, since the user is inputting variables, and at different parts in the game. Any help would be appreciated.
Here's my frame 1 code.
stop();
import fl.controls.Label;
import fl.controls.TextInput;
import flash.events.MouseEvent;
var total
total =(drinks * 0.06 * 100 * 1.055 / num * genderconstant) - (0.015 * hours)
var drinks=Number;
var hours=Number;
//inputs weight
var WeightTI:TextInput = new TextInput();
var tf:TextFormat = new TextFormat();
var str:String = WeightTI.text;
var num:Number = Number(str);
addChild(WeightTI);
// get key presses only when the textfield is being edited
WeightTI.addEventListener(KeyboardEvent.KEY_DOWN,handler);
function handler(event:KeyboardEvent){
// if the key is ENTER
if(event.charCode == 13){
// your code here
trace(Number(WeightTI.text));
trace(num);
}}
WeightTI.restrict = "0-9 .0-9";
tf.font = "Segoe UI";
tf.color = 000000;
tf.size = 16;
WeightTI.move(175, 234);
WeightTI.setSize(99, 27);
WeightTI.setStyle("textFormat", tf);
//inputs gender constant
boy_btn.label = "Male";
boy_btn.value = "Male";
girl_btn.label = "Female";
girl_btn.value = "Female";
boy_btn.move(177, 282);
girl_btn.move(300, 282);
var genderconstant = 0;
boy_btn.addEventListener(MouseEvent.CLICK, selectBoy)
function selectBoy(event:MouseEvent):void
{
genderconstant = 7.5;
trace(genderconstant);
}
girl_btn.addEventListener(MouseEvent.CLICK, selectGirl)
function selectGirl(event:MouseEvent):void
{
genderconstant = 9;
trace(genderconstant);
}
//inputs number of drinks
var q1
var q2
var q3
var q4
var q5
var q6
start_btn.addEventListener(MouseEvent.CLICK, startGame)
function startGame(event:MouseEvent): void
{
gotoAndStop(2);
trace(Number(WeightTI.text));
}
trace(num);
Copy link to clipboard
Copied
I do not understand the problem
Maybe you need
function calculate():void{
total =(drinks * 0.06 * 100 * 1.055 / num * genderconstant) - (0.015 * hours)
}