Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 4941 Flash Sites | 1 New Flash Links
What's New | Top 100 Flash Site

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


Random Links | Add your own Flash Related Links
Flash Tutorials 1481 Tutorials 7 New Tutorials Added!
What's New | Top100

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories Building a Text Game
Author: Troy Limacher | Website: www.geocities.com/helenandtroyuk |

 
Page 2
«prev 1 2 3 4 next»

Script Structure

The 'Code' Layer is made up of 3 keyframes.  I've added all functions into the first keyframe to keep things tidy,
these functions will all be called from the second keyframe script.  I've added an explanation to each line of
script, but will add more detailed explanation in the next section.
In the first keyframe copy & paste this script in -

//GENERAL STUFF
globalStyleFormat.textFont = "TimesNewRoman"; //sets the font
globalStyleFormat.applyChanges("textFont"); //sets the font
_root.listbox1.setAutoHideScrollBar(true); //hides the scrollbar on the items listbox
_root.help._visible = false; // hides help option until it is called for
_root.Place = 0; // Sets position or scene in game
_root.Object1Position = 0; //First object position, this object will be found in Place 0.
ResetAll();
function ResetAll() {
 _root.inputy = ""; //Empty input line
 _root.image1._visible = false; //Clear image box
 _root.objecty = ""; //Empty object line
 _root.Object1 = 0; // Ensure First Object actions only occur once.
}
function ResetTextLine() {
 _root.inputy = ""; //Empty object line everytime return is pressed.
}
function AddObjects() {
 _root.listbox1.removeAll(); // Empty items held box
 if (_root.Object1Position == "bag") {
 _root.listbox1.addItemAt(0, "box"); //Update items held box
 }
}

In the Second Keyframe add -

if (_root.Place == 0.1) { //Examine Light
 _root.texty = "The light is very strange, it is unlike any other light you've seen before.";
 // IMAGES
 _root.image1._visible = true;
 ///////////////////////////
 if (Key.isDown(Key.ENTER)) {
 _root.Place = 0; //Go to Second Room
 ResetAll(); // Go to function in keyframe 1
 }
}
if (_root.Place == 0) { //First room
 _root.texty = "You have no idea where this place is.  Bright light illuminates the room from a strange pyramid shaped bulb overhead.  You squint at it but realize that this is unnecessary as the light is quite comfortable to look at directly.  The room is quite bare, there is a door to the right.";
 // IMAGES
 _root.image1._visible = true;
 ///////////////////////////
 if (Key.isDown(Key.ENTER)) {
 if ((_root.inputy == "open door") or (_root.inputy == "go right") or (_root.inputy == "right")) {
 _root.Place += 1; //Go to Second Room
 ResetAll(); // Go to function in keyframe 1
 }
 if ((_root.inputy == "examine light") or (_root.inputy == "look at light")) {
 _root.Place = 0.1; //Go to Second Room
 ResetAll(); // Go to function in keyframe 1
 }
 }
}
if (_root.Place == 1) { //Second Room
 _root.texty = "You step into a room very similar to the previous one, except one of the walls is completely covered by a mirror.  There is a door to the left leading back to the first room.  There is complete silence which makes you feel quite uncomfortable.";
 ///////////////////////////
 if (Key.isDown(Key.ENTER)) {
 if ((_root.inputy == "open door") or (_root.inputy == "go left") or (_root.inputy == "left")) {
 _root.Place -= 1; //Go to First Room
 ResetAll();
 }
 }
}
if (_root.Place == 1.1) {
 _root.texty = "You examine the box and notice it is made of 2 parts, 1 slides like a button.  You push the 2 parts together and there is a high pitched beep.  Nothing happens after that.";
 ///////////////////////////
 if (Key.isDown(Key.ENTER)) {
 _root.Place = 0;
 ResetAll();
 }
}
if (_root.Place == 1.2) {
 _root.texty = "You examine the box and notice it is made of 2 parts, 1 slides like a button.  You push the 2 parts together and there is a high pitched beep.  The glass windows seperate to reveal a larger room surrounding this one.  You walk out into a large hall...END OF GAME SAMPLE, FULL GAME TO BE POSTED SOON!";
 ///////////////////////////
 if (Key.isDown(Key.ENTER)) {
 _root.Place = 1.3;
 ResetAll();
 }
}
/////////////////////////////////////////////////
// OBJECTS AND EVENTS
if ((_root.Object1Position == _root.Place) and (_root.Object1 == 0)) {
 _root.objecty = _root.objecty+"There is a SMALL BOX SHAPED OBJECT on the floor. ";
 _root.Object1 = 1; //the purpose of object1 is just to ensure that this line is added only once.
}
if (Key.isDown(Key.ENTER)) {
 if ((_root.inputy == "get object") or (_root.inputy == "get SMALL BOX SHAPED OBJECT") or (_root.inputy == "get box") or (_root.inputy == "get small box shaped object")) {
 if (_root.Object1Position == _root.Place) {
 _root.listbox1.addItemAt(0, "box");
 _root.Object1Position = "bag";
 AddObjects();
 ResetAll();
 }
 }
 if ((_root.inputy == "drop object") or (_root.inputy == "drop SMALL BOX SHAPED OBJECT") or (_root.inputy == "drop box") or (_root.inputy == "drop small box shaped object")) {
 if (Object1Position == "bag") {
 _root.Object1Position = _root.Place;
 AddObjects();
 }
 }
 if ((_root.inputy == "use box") or (_root.inputy == "use SMALL BOX SHAPED OBJECT") or (_root.inputy == "use box") or (_root.inputy == "use small box shaped object")) {
 if ((Object1Position == "bag") and (_root.Place<>1)) {
 _root.Place = 1.1;
 }
 }
 if ((_root.inputy == "use box") or (_root.inputy == "use SMALL BOX SHAPED OBJECT") or (_root.inputy == "use box") or (_root.inputy == "use small box shaped object")) {
 if ((Object1Position == "bag") and (_root.Place == 1)) {
 _root.Place = 1.2;
 _root.Object1Position = 1000;
 AddObjects();
 }
 }
}
///////////////////////////////////////////////
//RESETTEXTLINE
if (Key.isDown(Key.ENTER)) {
 ResetTextLine();
}

In the Third Keyframe add -

gotoAndPlay(2);

«prev 1 2 3 4 next»

» Level Intermediate

Added: : 2003-10-20
Rating: 6.84 Votes: 40
Hits: 1261
» Author
I write Flashscript for a plasma screen in the CTRL Project in London.
» Download
Download the files used in this tutorial.
Download (162 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments