A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


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

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


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

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Webmaster (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume


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.49 Votes: 36
Hits: 1257
» 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
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs