Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Beginning Game Programming With Flash Chapter 8

Beginning Game Programming With Flash Chapter 8

|Views: 29|Likes:
Published by vietk52

More info:

Published by: vietk52 on Jun 06, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





This page intentionally left blank 
High Scores Game
Use a SharedObject
Use arrays
Use a timer
What Is a SharedObject?
The SharedObject class available in the Flash environment is used to store smallamounts of data on the client machine. It is very similar to a cookie, which is seton your local machine and whose value can be retrieved at a later time. TheSharedObject is one way to have
persistent data,
which means the value saved inthis object continues to be accessible even after the program is closed, unlikevariables in a program whose value is alive only as long as the program is open.
Uses of a SharedObject
There are many uses for a SharedObject. Some of these uses are:
A SharedObject can be used as a cookie to store data on the local machine.This data that is saved is accessible only to that single machine.
A SharedObject can be used to save data on a server. This data can be seenby many clients at one time. An example is a high-scores game where
chapter 8
 you can see the scores of different people and compare your score to theirscores.
A SharedObject can be used to provide real-time data sharing among many clients. An example is where all the airline reservation agents can see thesame number of seats available for any given flight, and once a ticket isbooked everybody has the updated data reflecting the total available seats.Limitations of the SharedObject include the following:
Sometimes .swf files are not allowed to write data to local SharedObjects.
Sometimes the local SharedObject may be deleted without your knowledge.For more information on SharedObjects, visit Adobe livedocs athttp://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html.In this chapter, we will only be looking at the first type of use, which is to savedata on your local machine. We will design a high scores game to show aSharedObject in action.
E x e r c i s e 8 . 1
Story Line 
The main theme of this game is to mimic a high score feature, which is common in games. Thegame keeps track of scores of 10 individuals playing on the same machine. The scores are rankedfrom highest to lowest. The game requires that the player be able to click on an object thatappears at random places. The goal is for the player to click on the object as many times aspossible within 20 seconds. The number of clicks is saved in the SharedObject and is displayed thenext time the player opens the game.
This phase includes the logical flow of your game depicted pictorially. Figure 8.1 shows thisprocess.
Game Assets 
The graphics you need for this game are all going to be button symbols. You will need a Startbutton, an object (also a button type) that will be placed randomly at different positions, a ClearScores button, and a Play Again button. Use your imagination and create the three buttons (Start,Clear All, and Play Again). For the object, create a button with a fancy shape, such as a teddybear, a rabbit, an orange, or whatever you fancy. In this game, a dog biscuit will be used as theclickable object. Make sure you choose button type for these game assets when you create thenew symbols.
164 Chapter 8
High Scores Game

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
theblessed liked this
lee182scribd liked this
colozha liked this
uks liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->