1 Reply Latest reply on May 28, 2012 8:30 AM by esdebon

# Help with Blood Alcohol calculator

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);

// get key presses only when the textfield is being edited

function handler(event:KeyboardEvent){

// if the key is ENTER

if(event.charCode == 13){

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;

function selectBoy(event:MouseEvent):void

{

genderconstant = 7.5;

trace(genderconstant);

}

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

function startGame(event:MouseEvent): void

{

gotoAndStop(2);

trace(Number(WeightTI.text));

}

trace(num);

• ###### 1. Re: Help with Blood Alcohol calculator

I do not understand the problem

Maybe you need

function calculate():void{

total =(drinks * 0.06 * 100 * 1.055 / num * genderconstant) - (0.015 * hours)

}