First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Troy Limacher | Website: http://www.geocities.com/helenandtroyuk

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<%lt%><%gt%>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);

» Level Intermediate

Added: 2003-10-20
Rating: 7 Votes: 39
(10 being the highest)
» Author
I write Flashscript for a plasma screen in the CTRL Project in London.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.