PDA

View Full Version : Score Board


m33gzz
11-12-2009, 02:04 PM
Hi was working a group project and one of my memebers just ran off so i'm left to fix her mess

Can someone help me? We need a score board that shows team names and scores in dynamic text boxes.
and we need to be able to go into an xml file to edit the team names and we have an input panel, we need it to be able to be typed in for the scores and then when you hit the update button the new score appears and replaces the old one.

m33gzz
11-12-2009, 05:10 PM
So this is our project, a scoreboard with animations, sounds a timer and it keeps track of all our teams names and scores.
The team names will be loaded in though an XML file and the scores should be updated by a panel we made that has input boxes and button that will be linked up with our dynamic text boxes that display the scores.

heres what we have, I'm stuck with the xml and the scores...that what we need.

package {

import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
import flash.media.*;
import flash.xml.*;
import flash.net.*;


public class ScoreBoard extends MovieClip {

private const SOURCE:String = "gradeData.xml";

private var timer:Timer;
private var nTime:Number;
private var iStopPoint:int;
private var textFormat:TextFormat;
private var teamNames:Array;
private var mySharedObject:SharedObject;

private var urlLoader:URLLoader;
private var urlRequest:URLRequest;
private var teamXML:XML;

private var kidsSoundFX:KidsSound = new KidsSound();
private var busSoundFX:BusSound = new BusSound();
private var soundChannel:SoundChannel = new SoundChannel(); // using this for all sounds
private var transform1:SoundTransform = new SoundTransform();

// -------------------------------------constructor

public function ScoreBoard() {

teamNames = new Array();


/*mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput1.text = mySharedObject.data.enteredText;
}
*/

//---
/*mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput2.text = mySharedObject.data.enteredText;
}
//---
mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput3.text = mySharedObject.data.enteredText;
}
//---
mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput4.text = mySharedObject.data.enteredText;
}
//---
mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput5.text = mySharedObject.data.enteredText;
}
//---
mySharedObject = SharedObject.getLocal("testy");
if (mySharedObject.data.enteredText != null) {
txtInput6.text = mySharedObject.data.enteredText;
}*/

//---



nTime = 0;
iStopPoint = 150;
textFormat = new TextFormat();
textFormat.font = "Score Board";
txtMins.embedFonts = true;
txtName1.embedFonts = true;
txtName2.embedFonts = true;
txtName3.embedFonts = true;
txtName4.embedFonts = true;
txtName5.embedFonts = true;
txtName6.embedFonts = true;
txtName7.embedFonts = true;
txtName8.embedFonts = true;
txtName9.embedFonts = true;
txtName10.embedFonts = true;
txtName11.embedFonts = true;
txtName12.embedFonts = true;
txtName13.embedFonts = true;
txtName14.embedFonts = true;
txtName15.embedFonts = true;
txtName16.embedFonts = true;
txtName17.embedFonts = true;
txtName18.embedFonts = true;
txtName19.embedFonts = true;
txtName20.embedFonts = true;


// create timer object
timer = new Timer(1000,150);

// setup event listeners

btnUpdate.addEventListener(MouseEvent.CLICK, onStore);

btnWalkBoy.addEventListener(MouseEvent.CLICK, onStartBoy);
btnWalkGirl.addEventListener(MouseEvent.CLICK, onStartGirl);
btnBus.addEventListener(MouseEvent.CLICK, onStartBus);
btnCar.addEventListener(MouseEvent.CLICK, onStartCar);
timer.addEventListener(TimerEvent.TIMER, onTimer);
btnStart.addEventListener(MouseEvent.CLICK, onStart);
btnReset.addEventListener(MouseEvent.CLICK, onReset);

//-------- create objects to load XML and setup
urlLoader = new URLLoader();
urlRequest = new URLRequest(SOURCE);
urlLoader.addEventListener (Event.COMPLETE, onLoaded);
urlLoader.load(urlRequest);

};


// ------------------------------------------------- private methods
private function refreshTimer():void {
//This is the function that makes the timer count down
txtMins.text = String(Math.floor((150 - timer.currentCount) / 60));
//txtMins.setTextFormat(textFormat);

var iSeconds:int = (150 - timer.currentCount) % 60;
if (iSeconds < 10) {
txtSec.text = "0" + iSeconds;
} else {
txtSec.text = String(iSeconds);
}
txtSec.setTextFormat(textFormat);
}

// ------------------------------------------------- event handlers


private function onStartCar(e:MouseEvent): void {
carDrive.play();
}

private function onStartBus(e:MouseEvent): void {
transform1.volume= 1;
busSoundFX.soundTransform=transform1;
soundChannel = busSoundFX.play(0,1);
//soundChannel = kidsSoundFX.play(0,1);
btnBus.addEventListener(Event.ENTER_FRAME, onMoveBus);
}

private function onStartBoy(e:MouseEvent): void {
sideBoy.play();
}

private function onStartGirl(e:MouseEvent): void {
sideGirl.play();
}

//private function onStore(e:Event):void {
//mySharedObject.data.enteredText = txtInput1.text;
//}
/*
function onStore(e:Event):void {
mySharedObject.data.enteredText = txtInput2.text;
}
function onStore(e:Event):void {
mySharedObject.data.enteredText = txtInput3.text;
}
function onStore(e:Event):void {
mySharedObject.data.enteredText = txtInput4.text;
}
function onStore(e:Event):void {
mySharedObject.data.enteredText = txtInput5.text;
}
function onStore(e:Event):void {
mySharedObject.data.enteredText = txtInput6.text;
}
*/
//----

private function onLoaded(e:Event):void {

urlLoader.removeEventListener(Event.COMPLETE, onLoaded);
teamXML = new XML(urlLoader.data);

txtName1.text =(teamXML.student.name) +" " + txtInput1.text;
txtName2.text =(teamXML.student.name) +" " + txtInput2.text;
txtName3.text =(teamXML.student.name) +" " + txtInput3.text;
txtName4.text =(teamXML.student.name) +" " + txtInput4.text;
txtName5.text =(teamXML.student.name) +" " + txtInput5.text;
txtName7.text =(teamXML.student.name) +" " + txtInput7.text;
txtName8.text =(teamXML.student.name) +" " + txtInput8.text;
txtName9.text =(teamXML.student.name) +" " + txtInput9.text;
txtName10.text =(teamXML.student.name) +" " + txtInput10.text;
txtName11.text =(teamXML.student.name) +" " + txtInput11.text;
txtName12.text =(teamXML.student.name) +" " + txtInput12.text;
txtName13.text =(teamXML.student.name) +" " + txtInput13.text;
txtName14.text =(teamXML.student.name) +" " + txtInput14.text;
txtName15.text =(teamXML.student.name) +" " + txtInput15.text;
txtName16.text =(teamXML.student.name) +" " + txtInput16.text;
txtName17.text =(teamXML.student.name) +" " + txtInput17.text;
txtName18.text =(teamXML.student.name) +" " + txtInput18.text;
txtName19.text =(teamXML.student.name) +" " + txtInput19.text;
txtName20.text =(teamXML.student.name) +" " + txtInput20.text;



}

/*private var carSoundFX:CarSound = new CarSound();
trace("carsound");*/

private function onMoveCar(e:Event): void { //// this will need a reset as it will be fired each time for set up

/*soundChannel = carSoundFX.play(0,5);*/
carDrive.play();
}




private function onMoveBus(e:Event): void {



bus.play();
bus.x = bus.x + 20;
if (bus.x > 1900) {
stop();
trace("stop");
bus.stop();
btnBus.removeEventListener(Event.ENTER_FRAME, onMoveBus);
}
}


// -------------------------------------- TIMER ------ event handlers, making the timer run and count down


private function onStart(e:MouseEvent):void {
nTime = 0;
refreshTimer();
timer.start();
}

private function onTimer(e:TimerEvent):void {
nTime++;
refreshTimer();
if (nTime >= iStopPoint) {
timer.reset();
}
}

function onReset (e:MouseEvent): void {
timer.reset();
refreshTimer();
}


//----
for (var n:int=0; n<teamXML.team[4].teams.length(); n++) {

trace("in loop: " + teamXML.[4].teams.[n]);

var teamy:Object = new Object();
teamy.name = "Team Awesome";
teamy.team = teamXML.team[4].teams[n];
aTest.push(teamy);

//aTest.push({name:"Testy", grade:gradeXML.student[4].grades.grade[n]});
}

trace(aTest[1].team);
}


}
}

m33gzz
11-12-2009, 09:00 PM
I still cant get this work.