01_ tisidelaso.ml10/12/ PMPage iBeginning Flash® Game Programming FORDUMmIES by Andy Harris‰ 01_ Beginning Flash game programming for dummies. Read more · Beginning Programming with Java For Dummies · Read more. Beginning Flash® Game Programming For Dummies®. Published by. Wiley Publishing, Inc. River Street. Hoboken, NJ

Beginning Flash Game Programming For Dummies Pdf

Language:English, Arabic, French
Genre:Health & Fitness
Published (Last):03.08.2016
ePub File Size:28.74 MB
PDF File Size:17.51 MB
Distribution:Free* [*Sign up for free]
Uploaded by: ALLEN

Download Title, Size, Download. Download the Source Code for Beginning Flash Game Programming For Dummies Download all the chapters source code for. Description this book Beginning Flash Game Programming For Dummies You can start game programming in a flash Here s how to create five. [site] Beginning Flash Game Programming For Dummies by Andy Harris. Book file PDF easily for everyone and every device. You can download and read .

No boring programming theory here, just the stuff you need to know to actually make something happen, and all in plain English. Build a brain-teasing math game, go classic with Pong, create monsters and mayhem, and much more. He taught young adults with severe disabilities for several years.

He also taught himself enough computer programming to support his teaching habit with freelance programming. Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun. He lectures in the applied computing program and runs the streaming media lab.

He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.

Andy welcomes comments and suggestions about his books. He can be reached at aharris cs. Table of contents Introduction. Part I: Basic Flash. Chapter 1: Chapter 2: Cruising and Using the Flash Environment. Part II: The Next Steps. Chapter 3: Altered States. Chapter 4: Getting with the Program. Chapter 5: Making an Interactive Game. Part III: Sprites, or Movie Clips. Chapter 6: It will be printed specifically to fill your order.

Please allow an additional days delivery time. The book is not returnable. Other Available Formats: Click on the link below to download the files you want. Choose a location to save the file on your hard drive. After the download is compete, run WinZip or another software program that decompresses.

Download the. Click to Download. If you want to modify the look of your button, you then have to edit it but one time; all the other buttons are immediately modified as well.

Adding state to your button You can make your buttons even better by applying a mouseover effect to them: That is, you can change a button so it looks depressed pushed down, not saddened when the mouse is over it or clicks it. How do you make a button depressed? Seriously, Flash has an easy way to add different appearances to a button: Edit the button. Right-click your button in the Library.

Choose Edit from the resulting menu. You see a screen much like Figure Notice the changes to the Timeline. The screen for editing a button. Choose a state. When you edit a button, you have all the normal tools at your disposal, but you also have a slightly different Timeline. The four boxes in the button editor refer to four different states of a button. To make your own event line, follow these steps: Select the second frame in the Timeline the frame labeled Over.

This new frame indicates how the button looks when the mouse is over it. Modify your button. Give your button another state. Basic Flash In the same way as creating a standard button, you can create another frame to indicate what the button should look like when the user clicks it: That is, the mouse is over the button, and one of the mouse buttons is being held down. I created three different views for my button by manipulating the border colors.

In the down state, the border colors are set to make the button look as if it has been pressed down into the page. The fourth frame is special because it is never shown to the user.

If your button is an odd shape say, text without a rectangle behind it , the user should be able to click near the text without hitting the text exactly to activate the button. You can draw a rectangle in the Hit frame to indicate what the clickable area will be. With ordinary rectangular buttons, I usually skip this step. Return to the main program. You can click this link to finish editing the button and get back to your main program.

Test your new button by running your program. Move your mouse over the button and click it to see all the various button states in action. After all, the whole point of a button is to look like it can be clicked. Here are a couple more little flourishes, though, that you can do to make the button act properly: Cruising and Using the Flash Environment 1.

To run this check a. Name the instance. Select the button.

Set its name to theButton in the Properties Inspector by typing the new name in the text box that reads. This is different than naming the button in the Library. On the Stage, you give each cookie its own name. Add text to your button. Buttons often have labels text for the user associated with them, so throw some text on top of your button.

Follow these steps to breathe life into your button: Display the Actions panel. The key to code is the Actions panel, usually located near the bottom of the layout. Use the menu at the extreme upper-right corner of the Actions panel to use expert mode. The Actions panel is where you write most of your code. Basic Flash 2. Choose the correct frame and layer. For this example, select Frame 1, Layer 1.

About the Author

The Actions panel title bar should read Actions - Frame. If the Actions panel title bar reads Actions - Button, select the frame in the Timeline before you add any code. There are many approaches to writing code in ActionScript. Other books or tutorials show you a different technique, but my technique pays big dividends when you want to build complex and extensible games easily.

I must stress this: The Actions window should read Actions - Frame. To get to the right place, click Frame 1, Layer 1 right before you begin typing the code.

Write some button-handling code. To create a button that responds to mouse input, type the following code exactly as it appears here, including spelling and capitalization: I use comments throughout my code. Cruising and Using the Flash Environment Why not incorporate text into the button?

You might wonder why I add text to the button after creating it rather than incorporating text into the button itself. That is, each instance of the button has its own label. If you try to modify the text on one button, you also change the text on all the buttons in the program. By adding the text as a separate element after you place the button, you get the same effect without much effort.

Building pseudocode for the event ActionScript is an event-driven language: That is, your program is designed to sit around and wait for certain events to occur. Pseudocode is a good way to do this.

Computers are extremely stupid. Be sure that you understand what you want the computer to do. Writing pseudocode shows you the tasks that you can translate as code in the picky language that the computer requires.

In essence, your code says the following: And this logic happens many times per second while the program is running. Basic Flash Responding to the button click The point of having buttons on the screen is to indicate to the user that something will happen when he clicks that button. For that reason, every button you create will have some sort of code attached that does something when the button is clicked.

The button has some built-in characteristics, including the ability to recognize certain events.

You are doing a number of interesting things when you write this code: Any button can respond to a number of events, but onRelease is the most commonly coded. This lets users touch a button without committing to it. The button behavior happens only if the user both presses and releases the mouse over the button.

Think of it this way: If you click the Launch the nuclear missiles button and then you change your mind, you can move the mouse off the launch button before you release the mouse button, and World War III can be averted. This little window pops up automatically when you use the trace statement while testing your program within the Flash environment.

If you use your program in a Web page or run the SWF file directly, all the trace statements are ignored. Cruising and Using the Flash Environment visible only in the Flash editor.

All the text you send to output should be in double quotes. The trace line is indented in my code to indicate that it is part of another structure. In a typical program, you usually have code with many layers of structure nested inside each other. Proper indentation can help you keep track of your intentions and prevent mistakes. Almost all your code lines will end with a semicolon. Professional software developers are often required to use a particular style, and programming teachers also often have specific style guidelines.

There are a number of style conventions writing guidelines in use. For example, the braces in a function might be on their own lines rather than on the same line as the function identifier. The code will work in the same way, regardless of this style nuance.

The programmer simply subscribes to a different style convention. Here you can see how to move data in and out of your programs, master some essential programming techniques, make random numbers, and make text change dynamically onscreen.

So there. Chapter 3 is all about the concept of state. You discover how to give your programs multiple personalities, and how to swap between the various states. You finish the part by building an adventure game. Chapter 4 describes the three moods of text in Flash. You read how to make and use random numbers, how to use conditions to change the way your code behaves, and how to convert various types of data when necessary. Chapter 5 describes how to make an educational game in some detail.

You build a math game that generates random math problems. For example, your game might have an introduction screen, a help page, the main game, and pages for winning and losing conditions. Each of these scenes is a state another little tidbit that could be handy if you find yourself magically transported into a computer science cocktail party. If you follow the instructions in this chapter step by step, you build a simple adventure game.

State of Nonconfusion The states of an game are like the scenes of a movie. Each movie scene describes a particular environment or situation but all the scenes work together to form the movie. The ghosts in Pac-Man are examples of different states. They look and act differently under different circumstances: The Next Steps The instructions in this chapter demonstrate how to create the adventure game featured in Figures through Bad news. A lifeboat!

Altered States Figure Uh, oh. Adding Keyframes Think of an adventure game as a series of situations. In each situation, you make a choice that can move you to a new situation which programmers call a state. In an adventure game, the user needs to have the sense of moving around. The Green Grass program shown in Figures and shows how a very simple game with two states could work.

The Next Steps Figure This could keep me busy for quite some time. In the Green Grass program, the entire game has two states: Each state has a button that allows the player to switch to the other state.

Beginning Flash Game Programming For Dummies

As you can read in Chapter 2, buttons use their own Timeline to handle various states. Most Flash games use the Timeline in a similar way to handle the notion of state. You can specify points on the timeline as keyframes something special happens during that frame. You can read about keyframes in Chapter 2, also. Because this technique is used in almost every Flash game, you need to know how to build multi-state games games that support more than one state.

To build the Green Grass game, follow these steps: Create a new program. Start in Frame 1, Layer 1. Altered States 2. Build the HERE page.

Build the button. Create a rectangle, select it, open the Symbol dialog box press F8 , and convert it to a button. If you wish, you can also modify the button properties.

Chapter 2 shows you how to build buttons. Add text to the button. Put the text over the button instead of incorporating it into the button. Make the second keyframe. Insert a new keyframe from the Insert menu or by pressing F6. Add a third keyframe. Insert another keyframe at Frame Your Timeline looks like Figure The Timeline now indicates two different states. It just gives you some breathing room that proves useful when you name the frames.

The Next Steps Modifying the second frame When you create a keyframe in Frame 10 see the preceding steps , Flash automatically duplicates everything in the first frame. Although they look the same, the objects in Frame 10 are different instances than those in Frame 1, and they can be modified independently. Modify the text. For this example, select Frame 10 in the Timeline and modify the text in the text boxes. Use the black arrow to move or select a text box.

Use the Text tool described in Chapter 2 to modify the text inside the text box. When you move between Frames 1 and 10, you see different text. If you incorporate the text directly into the button, you have a problem. Frame 1 and Frame 10 contain different instances of the same button like two cookies baked from the same recipe. If you change the text in one button, you change it in both.

Name the keyframes. Referring to the frames by number gets tedious, so name those frames. To give a frame a name a. Select the frame. Look at the Properties window at the bottom of the screen. Indicate a name for the label, as shown in Figure To create states in this program, name Frame 1 here and Frame 10 there.

Frame-name capitalization and spelling are very important. Follow the same rules for naming frames as for naming files: Use no spaces, no punctuation, and camel-case, all of which you can read about in Chapter 2. Name the buttons. Each button instance can have its own name. In the editor, I call the button that lives in the here frame btnGoThere and the one in the there frame btnGoHere. Name the frame. Insert text It might confuse you that btnGoHere is in the there frame, but it really makes sense when you think about it.

The name of the button indicates what the button does, not where it resides. The btnGoThere button goes there but is located here. Follow these rules for button names: I need it this easy because I get confused easily.

Creating the game animation loop Games usually are built with an animation loop. Different programming languages have different ways to construct this loop, but the main idea is always the same. The critical parts of the program repeat many times a second, responding to input from the user, manipulating objects onscreen, and displaying the results. Flash has an elegant technique for repeating the code on a particular frame, and this technique is the foundation of ActionScript game programming.

The here frame shows at first. In less than a second, the there frame shows up. A little history lesson is in order. Flash was first an animation tool, and animation is still its first inclination.

Animators normally use the Timeline to specify when certain activities happen. In its default setting, Flash shows 12 frames per second fps. So, before you put any code in the program, Flash assumes that the program is a normal animation.

Beginning Programming For Dummies

In the example program, it shows Frame 1; then at Frame 10 almost one second later , it reaches a keyframe. Remember that a keyframe is a hint that something has changed on the Stage, so Flash now displays the new there, in this example information on the Stage.

This works great for standard, noninteractive animation, but the whole point of computer games is to let the player have some control. Game programmers subvert the Timeline to their own purposes.

Rather than letting the Timeline run on its own, programmers prefer to let the program perseverate over and over on one frame until the user somehow indicates it is time to go on. Go make friends with a dictionary. Many games that can last for hours use only two or three keyframes on the Timeline! To keep a multi-state program looping on only one frame, follow these steps: Type the following script in the Actions panel: Swapping states After you create a game with multiple states, you need code to switch between the various states.

Each button has code that sends the program to a new keyframe. Altered States stop ; btnGoThere. It then creates an event handler for the button on this frame. When that button is clicked, the program goes to a frame called there.

The Flash program is a MovieClip object. Throughout this book, I point out a lot more about objects in general, and especially the amazing MovieClip. The MovieClip object has all kinds of built-in characteristics and abilities.

You can use code to tell the MovieClip what to do. In this case, when the user clicks a button named btnGoThere, I want the main movie to move to a frame called there and loop that frame indefinitely. The gotoAndStop command is a built-in feature of MovieClip. The program looks for a frame with the specified name and moves control to that frame. The button in this frame is btnGoHere, and its job is to send control back to the here frame.

Making a Great Adventure With text boxes, buttons, and the notion of state, you have all the tools you need to build a great adventure game. Before you read on, try the shipwreck game yourself. Check it out at www.

You must, therefore, take some time to organize your thoughts before turning on the computer. Most adventure games begin life as diagrams. Figure shows you my diagram for the shipwreck adventure game. An adventure game is a series of Drown decisions. Building a fire is an endless trap as you know if you watch those reality shows featuring people on deserted islands. As small and simple as this game is, thinking it out still took quite some time.

The process of planning all the decisions and figuring out how they fit together is a challenge in its own right.

I did try to keep it organized: Each decision has descriptive text and a button or two at the bottom to indicate actions. All use the same font and button styles. To let the text speak for itself, I decided not to incorporate graphics or sound into this program. Setting the stage After you have a plan for your epic game, plan the general layout of your program. The first keyframe is simply an introduction to the game, but it sets the stage pun intended for everything that follows.

Every page will have a large text box describing the current scene as well as one or two buttons on the bottom. Make your life easier: Get these big-picture ideas right the first time rather than change them after you write the entire program: Follow these steps: Set up a large text box in the middle of the screen.

Type some sample text in the text box so you can see how it looks. Choose a font size and color that go well with the theme of your game. I wanted my buttons to look nautical, so I created a special ribbon shape. You can make buttons look like anything you want, but if you want to make buttons like mine, follow these steps: Build a normal rectangle.

Start by drawing a normal rectangle onscreen. Modify your button shape. Use the black arrow Selection tool on the Tools palette to modify your rectangle. When you move the black arrow near one of the sides of the rectangle, note how the cursor changes: This indicates that you can bend that side.

You can use a similar trick to move the corners. Make your shape into a button object. You can then add other states as described in Chapter 2. I used the Gradient tool in the Color Mixer to get a nice blend of colors.

The color mixer is available in the panel stack. Add other button states if you wish, such as over or down. You can change it later. After you create the button, place a text box over the button so you can add text. Creating the diagram nodes After you have the first frame done, give it a name and then add a keyframe.

I like to put my keyframes ten frames apart so I can read the labels on the Timeline. Name each keyframe when you build it. To keep things consistent, I recommend copying the frame name onto your diagram as well. Editing the nodes Your game state diagram is the key for building the entire game.

Do these steps on each keyframe to make the nodes described in your diagram: Change the text boxes. Altered States Change the text for each frame to contain a description of the scene and a the new dilemma facing the player. Make the needed buttons.

If the node has two or more choices, drag more button instances from the Library. Read about the Library in Chapter 1. Add a text box on top of the new button to give it some text. Name each button carefully. I like to use a mnemonic name for what the button should do.

For example, if the button should go to the buildFire frame, call the button something like btnBuildFire. This practice makes it easy for you to determine what code should be written for the button.. The Onionskin buttons are small icons underneath the Timeline. The most useful icon looks like an outlined square behind a blue square.

You can drag selectors on the Timeline to indicate which other frames are visible. This makes it easy to get a consistent look between frames. Coding the buttons You could test your program now, but it would run in a straight line under the strict control of the Timeline. Coding gives the player the ability to control his own experience. Every button in the program needs code to tell Flash what to do when the user clicks it. All the buttons do the same basic task: Go to a frame and stop there.

As an example, Figure illustrates the code for my jump frame. The frame occurs when the player jumps into the water near the beginning of the adventure. At this point, he can choose to swim either toward a lifeboat or some debris floating in the water. I created a button for each option, named btnLifeboat and btnDebris. Gotta love the logic of mnenomics. The Flash editor after I write the jump frame. This code is very much like the code from the Green Grass program earlier in the chapter.

Each button has code telling Flash what to do when that button is clicked. Every keyframe has code much like this but adjusted to reflect the buttons in that frame as well as the new frames that the buttons indicate. Resist the temptation to use this shortcut. You will outgrow the capabilities of the behavior mechanism very quickly. But the real point is to make your own game. Use mine as a guideline and look at it for ideas or help when you get stuck, but make your own game.

I slightly modified the HTML files containing all the programs in this book: I added a source code listing. You can see every line of code in the program without having to open the file in Flash. You can check the code at www. To get started, follow these steps: Start with a diagram. Break your story into nodes.

Give each node a name, a description, and a list of choices. Each choice should point to another node. You can even use a software tool such as Microsoft Visio or open source tools like dia. I include a copy of this software on the Web site that accompanies this book. I tried.

I got hopelessly confused. Build the first couple of frames, complete with buttons and code, and test them. Extend and modify. After you have things working on the first few frames, you can go crazy. You did make a diagram, right? Embellish the program. You can add graphics to your program.

I show you how to do more elaborate graphics, animation, and sound effects in later chapters. You can always come back and embellish your program when you know some other tricks. Have fun and write a masterpiece!

The computer gets information from the user in some form, manipulates that information, and sends information back to the user. In this way, games are just like any other kind of computer programming.

This chapter shows you a little about how computers work with information and how they make basic decisions based on that information. Along the way, you build programs that roll dice and make decisions. Somehow, you need Flash to read text that the user types onto the screen and then change text onscreen while the program runs. The greeting program featured in Figures and illustrates a basic form of communication between the computer and a human player. The player enters his name into a text box and is about to click the button.

The computer greets the player in a burst of familiarity. The user types text into a specially designated text area, and the button outputs a greeting based on that text. The secret ingredient of this program is the various subspecies of text areas. Flash supports three different types of text areas — static, dynamic, and output — each with different capabilities. You set up the text when designing the game: Dynamic text In comparison with static text, dynamic text can be changed by the program.

Dynamic text boxes can be named, just like buttons. Users can select text in a dynamic text box and also copy values from dynamic text, but users can neither write directly into these boxes nor paste values into them. Dynamic text is usually used to send changeable information to the user.

In the greeting program, the output text box the one that contains the final greeting is the only dynamic text box. Input text Input text lets the user type a value into the computer. The program can read this text and manipulate it. The Next Steps Input text is almost always either named or associated with a variable.

This chapter shows you how to associate a variable to a text field — a really easy and useful technique. In the greeting program, the field where the user types a name is an input text box. Building the Greeting Program The greeting program is relatively simple to build.

The following sections show you how to start by setting up your form with several kinds of text boxes. Adding text fields to the Stage The Text tool is used to place text elements on the screen.The most useful icon looks like an outlined square behind a blue square.

If you want, you can just download files from the Web site and start playing away. Bad news. Building the condition if statements are great, but they use another important programming idea called a condition. You can make button clones by dragging the button from the Library. This chapter helps you build a basic adventure game, and along the way, you get chummy with the basics of the Flash interface.

HANG from Fort Worth
Please check my other posts. I enjoy ssireum. I do relish reading comics weakly .