• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with Blood Alcohol calculator

New Here ,
May 27, 2012 May 27, 2012

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

TOPICS
ActionScript

Views

679

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 28, 2012 May 28, 2012

Copy link to clipboard

Copied

LATEST

I do not understand the problem

Maybe you need

function calculate():void{

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines