AS3 student needs help!
Hi readers I'm new to AS3 and Im not too sure who to ask for help so I thought I would try here first! (If some can recommend a better place please do!)
I'm trying to work out txt boxes....
I cant figure out what's going wrong here.
I wasn't able to use the Number variable to store inputs from the text boxes. So I looked up how to convert them to strings... I thought that would solve all my problems but now I just get a return of "NaN" when I press my button. Anyone know what's wrong with my Script??
import flash.events.MouseEvent;
// HomeWork week 2 - Jack McCallum - 3/8/2011
// Take input from 4 text fields. The number of fruit and payment.
// Output in a textbox the change from the transaction
stop(); //a wee stop button
var pricePlum:Number = 2.0;
var priceGrape:Number = 2.10;
var pricePeach:Number = 2.90;
// super cool variable names go here
var numPlum = Number(input1);
var numGrape = Number(input2);
var numPeach = Number(input3);
var payment = Number(input4);
var changy:Number;
// It wouldnt let me input using "number" variable so I tryed coverting them all to strings and then ouput as strings
var input1:String;
var input2:String;
var input3:String;
var input4:String;
var outputText = String(changy);
fruitButton.addEventListener(MouseEvent.CLICK, nextClick);//if I click the button stuff happens
//below is the main function wich calls the other functions. it is suposed to take buyFruit ouput and put it in a text box.
function nextClick(myNextEvent:MouseEvent):void{
captureText();
buyFruit();
textChange.text = outputText;
}
// hmmm why wont you work?
function captureText():void {
input1 = textPlum.text;
input2 = textGrape.text;
input3 = textPeach.text;
input4 = textPayment.text;
}
//calculates the change by: payment minus number of fruit times price etc.
function buyFruit():Number
{
return changy = payment -((numPlum * pricePlum)+(numGrape * priceGrape)+(numPeach * pricePeach));
}