[FONT=Verdana][SIZE=2][COLOR=Black]I’m in a Web Design class and atm, I’m working on chapter 8 of Flash CS5 case problem.
I have to make a calculator. Can I just say that AS3 makes me frusterated? D:
Anyway, after I finished what the book told me to do whilst getting confused in some areas, I got many compiler errors. I managed to get rid of them but in the end, my calculator isn’t working, haha.
Here’s the whole code:
import flash.events.MouseEvent;
calcTotal_btn.addEventListener(MouseEvent.CLICK, calculateTourCost);
function calculateTourCost(event:MouseEvent):void {
var totalCost:Number;
var base_cost:Number;
var people:Number = int(numberOfPeople.text);
var cost_per_person:Number;
if (people < 8)
{
cost_per_person = 10;
}
if (people < 7 > 16)
{
cost_per_person = 8;
}
if (people < 15)
{
cost_per_person = 5;
}
//Use the switch statement to assign the tour's base cost
switch (tourType_txt.text)
{
case "A" :
case "a" :
base_cost = 20;
break;
case "B" :
case "b" :
base_cost = 25;
break;
case "C" :
case "c" :
base_cost = 30;
break;
default :
base_cost = 40;
}
//Determines total cost
people = int(numberOfPeople) + int(base_cost);
totalCost = people * cost_per_person;
totalCost = (totalCost);
}
If anyone can help me out, I’d greatly appreciate it.
[/COLOR][/SIZE][/FONT]