Copy link to clipboard
Copied
http://imageshack.us/a/img59/6380/qeup.png
http://imageshack.us/a/img203/7864/9zur.png
So, long story short, here is what I've learned to use so far: if/else statements, while/for loops, and counters. I need to create a Weight Calculator that allows me to choose to enter in Metric or Imperial IBM. I also need to determine the Height in metres or inches. Regardless, I am stumped; I do not know how to start the program let alone complete it. This is the code I have so far:
"var body_txt:TextField = new TextField();
body_txt.x = 225;
body_txt.y = 300;
body_txt.autoSize = TextFieldAutoSize.LEFT;
var myFormat:TextFormat= new TextFormat();
var yourName:String;
var yourSystem:String;
var yourHeight:String;
var total:Number;
yourName = name_txt.text;
yourSystem = system_txt.text;
yourHeight = height_txt.text;
blue_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void {
addChild(body_txt);
body_txt.text= ""+ yourName +"'s ideal weight will be"
}"
I was thinking about starting with an "if statement" but I think there can be many other possibilities.
Copy link to clipboard
Copied
Start with gaining an understanding of the elements involved. especially the equations. You do not want to assign, process, or calculate anything until after the button is clicked.
Is this a school assignment?
Copy link to clipboard
Copied
It is indeed a school assignment. 50% of the assignments I complete are half-finished, however, due to lack of application and knowledge in this type of subject I suppose. I can only work with Layman's terms, as sad as it is.
Copy link to clipboard
Copied
There is one more question I would like to ask: How do you divide?
Metric:Weight (kg) = height (metres) × height (metres) ÷ 25
Imperial: Weight (pounds) = height (inches) × height (inches) ÷ 25 ÷ 703
I am trying to use those two formulas to find the Metric and Imperial values, and here is what I have so far:
var yourMetric:Number;
var yourImperial:Number;
yourMetric = height_txt.text * height_txt.text/25;
yourImperial = height_txt.text * height_txt.text/25/703;
I get 5 errors saying "Implicit coercion to a type of value", etc. Using "String" gets me even more errors, so I use "Number" instead. What am I doing wrong? Is the divide sign that I am using wrong?
"/"
Copy link to clipboard
Copied
I suppose
height_txt.text
is some kind of input textfield.
cast the string that you entered in a textfield as Number, to use it in a calculation.
yourMetric = Number(height_txt.text) * Number(height_txt.text)/25;
the divide signs are fine
Find more inspiration, events, and resources on the new Adobe Community
Explore Now