Search tutorials
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 |
| » 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) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


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