:puzzle: I have created a basic footy scoreboard with number of goals, behinds and total for both home and away team. The winner/ or currently winning team
is displayed at a textbox called ‘Leader’ and this all happen when button GO is pressed down. Below is my whole thing
// Function
function FootyScoreboard(evt:MouseEvent):void {
// Variables
var iVisGoals:int;
var iHomeGoals:int;
var iVisBehinds:int;
var iHomeBehinds:int;
var iVisTotal:int;
var iHomeTotal:int;
var iLeader:String;
var iLeadPoint:int;
// Input
iHomeGoals = parseInt(HomeGoals.text);
iHomeBehinds = parseInt(HomeBehinds.text);
iVisGoals = parseInt(VisGoals.text);
iVisBehinds = parseInt (VisBehinds.text);
// Processing
iVisTotal = (iVisGoals6)+iVisBehinds
iHomeTotal = (iHomeGoals6)+iHomeBehinds;
// Output
HomeTotal.text = (iHomeTotal.toString());
VisTotal.text = (iVisTotal.toString());
if (iHomeTotal == iVisTotal) {
Leader.text = “Draw”;
}
if (iHomeTotal > iVisTotal) {
Leader.text = “Home”;
}
if (iHomeTotal < iVisTotal) {
Leader.text = “Visitors”;
}
}
// Event Listeners
btnGo.addEventListener(MouseEvent.CLICK, FootyScoreboard);
What i have to do now is in a textbox called LeadPoint, put how much points the winner is winning by. But i cannot work out how i will do that.
I tried doing LeadPoint.text = iHomeTotal - iVisTotal which doesnt really work, and i did iLeadPoint = iHomeTotal - iVisTotal for ‘if (iHomeTotal > iVisTotal)’ and reverse for Vis > Home but only one worked!! meaning if Home scored 10 and Visitors scored 5, it will say 5 and if Vis scored 10 and Home scored 5, i will say -5.
Currently when i put in the number of goals and behinds it calculates the total and the winner as you can probably see up there.
Textbox where leading points will be displayed is currently empty . Please explain or let me know what i can do. Even small help will
really be appreciated. if anythings unsure please let me know so ill try to explain whats going on.