Part 6: End Screen
The final support class we need for this lesson is EndScreen. The EndScreen.as is essentially the same (right now) as the TitleScreen.as , execpt it will display the final score the player achieved. FEndScreen in the library looks like this:

The only difference between TitleScreen.as and EndScreen.as of any significance is the setFinalScore() function.
public function setFinalScore(scr:Number) {
finalScore = scr;
}
This function is used to set the score that will be displayed on the the FEndScreen. Below is the full code for EndScreen.as.
import mx.events.EventDispatcher;
import mx.utils.Delegate;
class EndScreen extends MovieClip {
var button_playagain:MovieClip;
var finalScore:Number = 0;
function EndScreen() {
EventDispatcher.initialize(this);
button_playagain.onRelease = Delegate.create(this,EventClickPlayButton);
finalScore = 0;
}
public function setLocation(x:Number,y:Number) {
this._x = x;
this._y = y;
}
public function setFinalScore(scr:Number) {
finalScore = scr;
}
function EventClickPlayButton() {
this.dispatchEvent({type:"EventCloseEndScreen"});
}
public function addEventListener(){/*Interface Stub*/}
public function removeEventListener(){/*Interface Stub*/}
public function dispatchEvent(){/*Interface Stub*/}
}
Read the rest of the series: ‘Anatomy of a Flash Game’
- Anatomy of a Flash Game: Lesson 1 – Setting up the game
- Anatomy of a Flash Game: Lesson 2 – Creating Enemies & The Game Environment
- Anatomy of a Flash Game: Lesson 3 – MochiAds, MochiBot and MochiAds Leaderboards
