基本信息
源码名称:Macromedia Flash MX ActionScript for Fun and Games.pdf
源码大小:8.99M
文件格式:.pdf
开发语言:Flash
更新时间:2020-11-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
Macromedia Flash MX ActionScript for Fun and Games by Gary Rosenzweig
Contents Introduction . . . . . . . . . . . . . . . . . .1 1 Flash Elements Used to Make Games and Toys . . . . . . . . . . . . . . .9 The Flash Interface . . . . . . . . . . . . . . . .10 The Main Flash Window . . . . . . . . . . .10 Panels . . . . . . . . . . . . . . . . . . . . . . .11 Menu Items . . . . . . . . . . . . . . . . . . . .14 Creating Buttons . . . . . . . . . . . . . . . . . .19 The Button Timeline . . . . . . . . . . . . .19 Button Example . . . . . . . . . . . . . . . . .20 Creating Text . . . . . . . . . . . . . . . . . . . .21 Text Properties . . . . . . . . . . . . . . . . .21 Dynamic Text . . . . . . . . . . . . . . . . . .22 Input Text . . . . . . . . . . . . . . . . . . . . .23 Importing Media into Flash . . . . . . . . . . .23 Bitmaps . . . . . . . . . . . . . . . . . . . . . .23 Sounds . . . . . . . . . . . . . . . . . . . . . . .24 Organizing Your Movie . . . . . . . . . . . . . .26 The Library . . . . . . . . . . . . . . . . . . . .26 Frames . . . . . . . . . . . . . . . . . . . . . . .27 Layers . . . . . . . . . . . . . . . . . . . . . . .27 Scenes . . . . . . . . . . . . . . . . . . . . . . .28 Off-Stage Area . . . . . . . . . . . . . . . . .28 Finishing Your Movie . . . . . . . . . . . . . . .29 Final Checklist . . . . . . . . . . . . . . . . . .29 Publishing . . . . . . . . . . . . . . . . . . . . .30 Putting Flash on the Web . . . . . . . . . .32 2 An Introduction to ActionScript . . . .35 Lesson 1: What Is ActionScript and Where Does It Go? . . . . . . . . . . . . . . . .36 Frame Scripts . . . . . . . . . . . . . . . . . .36 Button Scripts . . . . . . . . . . . . . . . . . .37 Movie Clip Scripts . . . . . . . . . . . . . . .37 Lesson 2: Using the Actions Panel . . . . . .37 Lesson 3: Your First ActionScript Program . . . . . . . . . . . . . . . . . . . . . . . .39 Lesson 4: Controlling Flash Playback . . . .41 00 0789727994 fm 6/20/02 2:37 PM Page iv Lesson 5: Creating Buttons to Give the User Control . . . . . . . . . . . . . . . . . . . . .43 Lesson 6: Animating with ActionScript . . .46 Lesson 7: Letting the User Control Movie Clips . . . . . . . . . . . . . . . . . . . . .48 Lesson 8: Using Variables . . . . . . . . . . . .49 Lesson 9: Performing Operations . . . . . .50 Lesson 10: Conditional Statements . . . . .52 Lesson 11: Loops . . . . . . . . . . . . . . . . .53 Lesson 12: Text and Strings . . . . . . . . . .55 Lesson 13: Creating Functions . . . . . . . .56 Lesson 14: Arrays . . . . . . . . . . . . . . . . .58 3 ActionScript Elements Used to Make Games and Toys . . . . . . . . . .61 Lesson 15: Controlling the Playback of a Movie Clip . . . . . . . . . . . . . . . . . . .62 Lesson 16: Controlling the Properties of a Movie Clip . . . . . . . . . . . . . . . . . . .64 Lesson 17: Dragging and Dropping Movie Clips . . . . . . . . . . . . . . . . . . . . .66 Lesson 18: Movie Clips and Levels . . . . .68 Lesson 19: Duplicating Movie Clips . . . . .70 Lesson 20: Controlling Multiple Movie Clips . . . . . . . . . . . . . . . . . . . . .73 Creating an “Actions” Movie Clip . . . .73 Event Handlers . . . . . . . . . . . . . . . . .76 Lesson 21: Detecting Collisions . . . . . . . .76 Lesson 22: Using Movie Clips to Change What Is on the Screen . . . . . . . .78 Lesson 23: Accepting Keyboard Input . . .79 Lesson 24: Playing Sounds . . . . . . . . . . .81 4 The Game-Creation Process . . . . . .85 Flash and Games . . . . . . . . . . . . . . . . . .86 Weaknesses . . . . . . . . . . . . . . . . . . .86 Strengths . . . . . . . . . . . . . . . . . . . . .86 Parts of a Game . . . . . . . . . . . . . . . . . .87 Loading Screen . . . . . . . . . . . . . . . . .87 Splash Screen . . . . . . . . . . . . . . . . . .88 Instructions . . . . . . . . . . . . . . . . . . . .88 Backgrounds . . . . . . . . . . . . . . . . . . .89 Game Over Screen . . . . . . . . . . . . . .89 00 0789727994 fm 6/20/02 2:37 PM Page v How to Program . . . . . . . . . . . . . . . . . .90 Breaking Down Problems . . . . . . . . . .90 Good Programming Practices . . . . . . .91 Debugging . . . . . . . . . . . . . . . . . . . .92 Testing . . . . . . . . . . . . . . . . . . . . . . .92 Games and Legal Issues . . . . . . . . . . . . .92 Altering the Games in This Book . . . . . . .93 Changing the Graphics . . . . . . . . . . . .94 Altering the ActionScript . . . . . . . . . .94 Combining Games . . . . . . . . . . . . . . .94 Top Pitfalls . . . . . . . . . . . . . . . . . . . . . .94 Movie Clip Names . . . . . . . . . . . . . . .94 Linkage Properties . . . . . . . . . . . . . . .94 Movie Clip Levels . . . . . . . . . . . . . . .95 Forgetting the Underscore . . . . . . . . .95 Splice and Slice . . . . . . . . . . . . . . . . .95 Global and Local Variables . . . . . . . . .95 5 ActionScript Design Effects . . . . . . .97 Expanding Buttons . . . . . . . . . . . . . . . .98 Project Goal . . . . . . . . . . . . . . . . . . .98 Approach . . . . . . . . . . . . . . . . . . . . .98 Preparing the Movie . . . . . . . . . . . . . .99 Writing the Code . . . . . . . . . . . . . . . .99 Loose Ends . . . . . . . . . . . . . . . . . . .101 Other Possibilities . . . . . . . . . . . . . .102 Color Cycling Rotating Spiral . . . . . . . .102 Project Goal . . . . . . . . . . . . . . . . . .102 Approach . . . . . . . . . . . . . . . . . . . .102 Preparing the Movie . . . . . . . . . . . . .106 Color Cycling and Rotation . . . . . . . .107 Loose Ends . . . . . . . . . . . . . . . . . . .109 Other Possibilities . . . . . . . . . . . . . .109 Randomness and the Old Film Effect . . .109 Project Goal . . . . . . . . . . . . . . . . . .110 Approach . . . . . . . . . . . . . . . . . . . .110 Preparing the Movie . . . . . . . . . . . . .111 Writing the Code . . . . . . . . . . . . . . .112 Loose Ends . . . . . . . . . . . . . . . . . . .114 Other Possibilities . . . . . . . . . . . . . .114 Letter Movement . . . . . . . . . . . . . . . . .114 Project Goal . . . . . . . . . . . . . . . . . .115 Approach . . . . . . . . . . . . . . . . . . . .115 vi Macromedia Flash MX ActionScript for Fun & Games 00 0789727994 fm 6/20/02 2:37 PM Page vi Preparing the Movie . . . . . . . . . . . . .115 Writing the Code . . . . . . . . . . . . . . .116 Loose Ends . . . . . . . . . . . . . . . . . . .118 Other Possibilities . . . . . . . . . . . . . .118 Cursor Trail . . . . . . . . . . . . . . . . . . . .118 Project Goal . . . . . . . . . . . . . . . . . .119 Approach . . . . . . . . . . . . . . . . . . . .119 Preparing the Movie . . . . . . . . . . . . .119 Writing the Code . . . . . . . . . . . . . . .119 Loose Ends . . . . . . . . . . . . . . . . . . .121 Other Possibilities . . . . . . . . . . . . . .121 3D Illusions . . . . . . . . . . . . . . . . . . . . .121 Project Goal . . . . . . . . . . . . . . . . . .121 Approach . . . . . . . . . . . . . . . . . . . .122 Preparing the Movie . . . . . . . . . . . . .122 Writing the Code . . . . . . . . . . . . . . .122 Other Possibilities . . . . . . . . . . . . . .128 6 Toys and Gadgets . . . . . . . . . . . .129 The Magic Crystal Ball . . . . . . . . . . . . .130 Project Goal . . . . . . . . . . . . . . . . . .130 Approach . . . . . . . . . . . . . . . . . . . .130 Preparing the Movie . . . . . . . . . . . . .130 Writing the Code . . . . . . . . . . . . . . .132 Loose Ends . . . . . . . . . . . . . . . . . . .136 Other Possibilities . . . . . . . . . . . . . .136 Music Jukebox . . . . . . . . . . . . . . . . . .136 Project Goal . . . . . . . . . . . . . . . . . .136 Approach . . . . . . . . . . . . . . . . . . . .137 Preparing the Movie . . . . . . . . . . . . .138 Writing the Code . . . . . . . . . . . . . . .138 Other Possibilities . . . . . . . . . . . . . .140 Analog Clock . . . . . . . . . . . . . . . . . . .140 Project Goal . . . . . . . . . . . . . . . . . .140 Approach . . . . . . . . . . . . . . . . . . . .140 Preparing the Movie . . . . . . . . . . . . .142 Writing the Code . . . . . . . . . . . . . . .143 Other Possibilities . . . . . . . . . . . . . .145 Lava Lamp . . . . . . . . . . . . . . . . . . . . .145 Project Goal . . . . . . . . . . . . . . . . . .145 Approach . . . . . . . . . . . . . . . . . . . .146 Preparing the Movie . . . . . . . . . . . . .146 Contents vii 00 0789727994 fm 6/20/02 2:37 PM Page vii Writing the Code . . . . . . . . . . . . . . .147 Loose Ends . . . . . . . . . . . . . . . . . . .149 The Game of Life . . . . . . . . . . . . . . . .149 Project Goal . . . . . . . . . . . . . . . . . .150 Approach . . . . . . . . . . . . . . . . . . . .150 Preparing the Movie . . . . . . . . . . . . .151 Writing the Code . . . . . . . . . . . . . . .151 Loose Ends . . . . . . . . . . . . . . . . . . .154 Other Possibilities . . . . . . . . . . . . . .155 7 Construction Toys . . . . . . . . . . . .157 Drag-and-Drop Make-a-Fox . . . . . . . . . .158 Project Goal . . . . . . . . . . . . . . . . . .158 Approach . . . . . . . . . . . . . . . . . . . .158 Preparing the Movie . . . . . . . . . . . . .158 Writing the Code . . . . . . . . . . . . . . .159 Click-And-Switch Make-A-Fox . . . . . . . .163 Project Goal . . . . . . . . . . . . . . . . . .163 Approach . . . . . . . . . . . . . . . . . . . .163 Writing the Code . . . . . . . . . . . . . . .163 Loose Ends . . . . . . . . . . . . . . . . . . .165 Other Possibilities . . . . . . . . . . . . . .165 Sketchbook . . . . . . . . . . . . . . . . . . . . .165 Project Goal . . . . . . . . . . . . . . . . . .165 Creating a Simple Drawing Program . . . . . . . . . . . . . . . . . . . . .165 Creating a Complex Drawing Program . . . . . . . . . . . . . . . . . . . . .167 Adding Clear and Print Buttons . . . . .171 Loose Ends . . . . . . . . . . . . . . . . . . .172 Other Possibilities . . . . . . . . . . . . . .173 Music Mixer . . . . . . . . . . . . . . . . . . . .173 Project Goal . . . . . . . . . . . . . . . . . .173 Approach . . . . . . . . . . . . . . . . . . . .174 Preparing the Movie . . . . . . . . . . . . .174 Writing the Code . . . . . . . . . . . . . . .175 Loose Ends . . . . . . . . . . . . . . . . . . .177 Other Possibilities . . . . . . . . . . . . . .178 Dancing Fox . . . . . . . . . . . . . . . . . . . .178 Project Goal . . . . . . . . . . . . . . . . . .179 Approach . . . . . . . . . . . . . . . . . . . .179 Preparing the Movie . . . . . . . . . . . . .179 viii Macromedia Flash MX ActionScript for Fun & Games 00 0789727994 fm 6/20/02 2:37 PM Page viii Writing the Code . . . . . . . . . . . . . . .180 Loose Ends . . . . . . . . . . . . . . . . . . .182 Other Possibilities . . . . . . . . . . . . . .182 8 Hunt and Click Games . . . . . . . . .183 Find-A-Fox . . . . . . . . . . . . . . . . . . . . .184 Project Goal . . . . . . . . . . . . . . . . . .184 Approach . . . . . . . . . . . . . . . . . . . .185 Preparing the Movie . . . . . . . . . . . . .185 Writing the Code . . . . . . . . . . . . . . .186 Loose Ends . . . . . . . . . . . . . . . . . . .187 Other Possibilities . . . . . . . . . . . . . .188 Whack-A-Fox . . . . . . . . . . . . . . . . . . .188 Project Goal . . . . . . . . . . . . . . . . . .189 Approach . . . . . . . . . . . . . . . . . . . .189 Preparing the Movie . . . . . . . . . . . . .189 Writing the Code . . . . . . . . . . . . . . .190 Loose Ends . . . . . . . . . . . . . . . . . . .192 Other Possibilities . . . . . . . . . . . . . .192 Shoot-A-Fox . . . . . . . . . . . . . . . . . . . .193 Project Goal . . . . . . . . . . . . . . . . . .193 Approach . . . . . . . . . . . . . . . . . . . .194 Preparing the Movie . . . . . . . . . . . . .194 Writing the Code . . . . . . . . . . . . . . .195 Loose Ends . . . . . . . . . . . . . . . . . . .198 Other Possibilities . . . . . . . . . . . . . .198 Hunt-A-Fox . . . . . . . . . . . . . . . . . . . .198 Project Goal . . . . . . . . . . . . . . . . . .199 Approach . . . . . . . . . . . . . . . . . . . .199 Preparing the Movie . . . . . . . . . . . . .200 Writing the Code . . . . . . . . . . . . . . .200 Loose Ends . . . . . . . . . . . . . . . . . . .202 Other Possibilities . . . . . . . . . . . . . .202 9 Catch and Avoid Games . . . . . . . .203 Apple Catch . . . . . . . . . . . . . . . . . . . .204 Project Goal . . . . . . . . . . . . . . . . . .204 Approach . . . . . . . . . . . . . . . . . . . .205 Preparing the Movie . . . . . . . . . . . . .205 Writing the Code . . . . . . . . . . . . . . .206 Loose Ends . . . . . . . . . . . . . . . . . . .211 Other Possibilities . . . . . . . . . . . . . .212 Contents ix 00 0789727994 fm 6/20/02 2:37 PM Page ix Apple Letter Catch . . . . . . . . . . . . . . .212 Project Goal . . . . . . . . . . . . . . . . . .213 Approach . . . . . . . . . . . . . . . . . . . .213 Preparing the Movie . . . . . . . . . . . . .213 Writing the Code . . . . . . . . . . . . . . .214 Loose Ends . . . . . . . . . . . . . . . . . . .216 Other Possibilities . . . . . . . . . . . . . .216 River Rafting Game . . . . . . . . . . . . . . .216 Project Goal . . . . . . . . . . . . . . . . . .217 Approach . . . . . . . . . . . . . . . . . . . .217 Preparing the Movie . . . . . . . . . . . . .217 Writing the Code . . . . . . . . . . . . . . .218 Loose Ends . . . . . . . . . . . . . . . . . . .223 Other Possibilities . . . . . . . . . . . . . .223 Racing Game . . . . . . . . . . . . . . . . . . .223 Project Goal . . . . . . . . . . . . . . . . . .223 Approach . . . . . . . . . . . . . . . . . . . .224 Preparing the Movie . . . . . . . . . . . . .225 Writing the Code . . . . . . . . . . . . . . .225 Loose Ends . . . . . . . . . . . . . . . . . . .229 Other Possibilities . . . . . . . . . . . . . .230 10 Aim and Shoot Games . . . . . . . . .231 Move and Shoot the Balloons . . . . . . . .232 Project Goal . . . . . . . . . . . . . . . . . .232 Approach . . . . . . . . . . . . . . . . . . . .232 Preparing the Movie . . . . . . . . . . . . .233 Writing the Code . . . . . . . . . . . . . . .234 Loose Ends . . . . . . . . . . . . . . . . . . .241 Other Possibilities . . . . . . . . . . . . . .241 Aim and Shoot . . . . . . . . . . . . . . . . . .241 Project Goal . . . . . . . . . . . . . . . . . .242 Approach . . . . . . . . . . . . . . . . . . . .242 Preparing the Movie . . . . . . . . . . . . .243 Writing the Code . . . . . . . . . . . . . . .243 Loose Ends . . . . . . . . . . . . . . . . . . .246 Other Possibilities . . . . . . . . . . . . . .246 Balloon Invaders . . . . . . . . . . . . . . . . .247 Project Goal . . . . . . . . . . . . . . . . . .247 Approach . . . . . . . . . . . . . . . . . . . .247 Preparing the Movie . . . . . . . . . . . . .247 Writing the Code . . . . . . . . . . . . . . .248 x Macromedia Flash MX ActionScript for Fun & Games 00 0789727994 fm 6/20/02 2:37 PM Page x Loose Ends . . . . . . . . . . . . . . . . . . .251 Other Possibilities . . . . . . . . . . . . . .251 11 Ball-and-Paddle Games . . . . . . . . .253 Wall Ball . . . . . . . . . . . . . . . . . . . . . . .254 Project Goal . . . . . . . . . . . . . . . . . .254 Approach . . . . . . . . . . . . . . . . . . . .254 Preparing the Movie . . . . . . . . . . . . .255 Writing the Code . . . . . . . . . . . . . . .255 Loose Ends . . . . . . . . . . . . . . . . . . .259 Other Possibilities . . . . . . . . . . . . . .259 Paddle Ball . . . . . . . . . . . . . . . . . . . . .259 Project Goal . . . . . . . . . . . . . . . . . .259 Approach . . . . . . . . . . . . . . . . . . . .260 Preparing the Movie . . . . . . . . . . . . .261 Writing the Code . . . . . . . . . . . . . . .261 Loose Ends . . . . . . . . . . . . . . . . . . .265 Other Possibilities . . . . . . . . . . . . . .265 Paddle Bricks . . . . . . . . . . . . . . . . . . .265 Project Goal . . . . . . . . . . . . . . . . . .266 Approach . . . . . . . . . . . . . . . . . . . .266 Preparing the Movie . . . . . . . . . . . . .267 Writing the Code . . . . . . . . . . . . . . .268 Loose Ends . . . . . . . . . . . . . . . . . . .273 Other Possibilities . . . . . . . . . . . . . .273 3D Paddle Bricks . . . . . . . . . . . . . . . . .273 Project Goal . . . . . . . . . . . . . . . . . .274 Approach . . . . . . . . . . . . . . . . . . . .274 Preparing the Movie . . . . . . . . . . . . .274 Writing the Code . . . . . . . . . . . . . . .275 Loose Ends . . . . . . . . . . . . . . . . . . .280 Other Possibilities . . . . . . . . . . . . . .280 12 Quizzes and Word Puzzles . . . . . .281 Flash Quiz . . . . . . . . . . . . . . . . . . . . .282 Project Goal . . . . . . . . . . . . . . . . . .282 Approach . . . . . . . . . . . . . . . . . . . .282 Preparing the Movie . . . . . . . . . . . . .283 Writing the Code . . . . . . . . . . . . . . .284 Loose Ends . . . . . . . . . . . . . . . . . . .290 Other Possibilities . . . . . . . . . . . . . .290 Flash Trivia . . . . . . . . . . . . . . . . . . . . .290 Project Goal . . . . . . . . . . . . . . . . . .291 Approach . . . . . . . . . . . . . . . . . . . .291 Contents xi 00 0789727994 fm 6/20/02 2:37 PM Page xi Preparing the Movie . . . . . . . . . . . . .292 Writing the Code . . . . . . . . . . . . . . .292 Loose Ends . . . . . . . . . . . . . . . . . . .296 Other Possibilities . . . . . . . . . . . . . .297 Hangman . . . . . . . . . . . . . . . . . . . . . .297 Project Goal . . . . . . . . . . . . . . . . . .297 Approach . . . . . . . . . . . . . . . . . . . .297 Preparing the Movie . . . . . . . . . . . . .298 Writing the Code . . . . . . . . . . . . . . .298 Loose Ends . . . . . . . . . . . . . . . . . . .301 Other Possibilities . . . . . . . . . . . . . .302 Cryptogram . . . . . . . . . . . . . . . . . . . .302 Project Goal . . . . . . . . . . . . . . . . . .302 Approach . . . . . . . . . . . . . . . . . . . .303 Preparing the Movie . . . . . . . . . . . . .304 Writing the Code . . . . . . . . . . . . . . .304 Loose Ends . . . . . . . . . . . . . . . . . . .308 Other Possibilities . . . . . . . . . . . . . .309 13 Picture Puzzles . . . . . . . . . . . . . .311 Jigsaw Puzzle . . . . . . . . . . . . . . . . . . .312 Project Goal . . . . . . . . . . . . . . . . . .312 Approach . . . . . . . . . . . . . . . . . . . .313 Preparing the Movie . . . . . . . . . . . . .314 Writing the Code . . . . . . . . . . . . . . .314 Other Possibilities . . . . . . . . . . . . . .316 Sliding Puzzle . . . . . . . . . . . . . . . . . . .316 Project Goal . . . . . . . . . . . . . . . . . .317 Approach . . . . . . . . . . . . . . . . . . . .317 Preparing the Movie . . . . . . . . . . . . .317 Writing the Code . . . . . . . . . . . . . . .318 Loose Ends . . . . . . . . . . . . . . . . . . .321 Other Possibilities . . . . . . . . . . . . . .321 Matching Game . . . . . . . . . . . . . . . . . .321 Project Goal . . . . . . . . . . . . . . . . . .322 Approach . . . . . . . . . . . . . . . . . . . .322 Preparing the Movie . . . . . . . . . . . . .322 Writing the Code . . . . . . . . . . . . . . .323 Loose Ends . . . . . . . . . . . . . . . . . . .326 Other Possibilities . . . . . . . . . . . . . .326 Find the Picture . . . . . . . . . . . . . . . . . .326 Project Goal . . . . . . . . . . . . . . . . . .327 Approach . . . . . . . . . . . . . . . . . . . .327 xii Macromedia Flash MX ActionScript for Fun & Games 00 0789727994 fm 6/20/02 2:37 PM Page xii Preparing the Movie . . . . . . . . . . . . .328 Writing the Code . . . . . . . . . . . . . . .329 Loose Ends . . . . . . . . . . . . . . . . . . .331 Other Possibilities . . . . . . . . . . . . . .331 14 Brain Puzzles . . . . . . . . . . . . . . .333 Memory Game . . . . . . . . . . . . . . . . . .334 Approach . . . . . . . . . . . . . . . . . . . .334 Preparing the Movie . . . . . . . . . . . . .335 Writing the Code . . . . . . . . . . . . . . .336 Loose Ends . . . . . . . . . . . . . . . . . . .339 Other Possibilities . . . . . . . . . . . . . .339 Deduction . . . . . . . . . . . . . . . . . . . . . .339 Project Goal . . . . . . . . . . . . . . . . . .340 Approach . . . . . . . . . . . . . . . . . . . .340 Preparing the Movie . . . . . . . . . . . . .341 Writing the Code . . . . . . . . . . . . . . .342 Loose Ends . . . . . . . . . . . . . . . . . . .346 Other Possibilities . . . . . . . . . . . . . .346 Pegs . . . . . . . . . . . . . . . . . . . . . . . . .347 Project Goal . . . . . . . . . . . . . . . . . .347 Approach . . . . . . . . . . . . . . . . . . . .347 Preparing the Movie . . . . . . . . . . . . .348 Writing the Code . . . . . . . . . . . . . . .348 Other Possibilities . . . . . . . . . . . . . .352 Recursive Blocks . . . . . . . . . . . . . . . . .353 Project Goal . . . . . . . . . . . . . . . . . .353 Approach . . . . . . . . . . . . . . . . . . . .354 Preparing the Movie . . . . . . . . . . . . .354 Writing the Code . . . . . . . . . . . . . . .355 Loose Ends . . . . . . . . . . . . . . . . . . .359 Other Possibilities . . . . . . . . . . . . . .359 15 Casino and Card Games . . . . . . . .361 Slot Machine . . . . . . . . . . . . . . . . . . . .362 Project Goal . . . . . . . . . . . . . . . . . .363 Approach . . . . . . . . . . . . . . . . . . . .363 Preparing the Movie . . . . . . . . . . . . .363 Writing the Code . . . . . . . . . . . . . . .364 Loose Ends . . . . . . . . . . . . . . . . . . .368 Other Possibilities . . . . . . . . . . . . . .368 Video Poker . . . . . . . . . . . . . . . . . . . .369 Project Goal . . . . . . . . . . . . . . . . . .369 Approach . . . . . . . . . . . . . . . . . . . .370 Contents xiii 00 0789727994 fm 6/20/02 2:37 PM Page xiii Preparing the Movie . . . . . . . . . . . . .370 Writing the Code . . . . . . . . . . . . . . .371 Loose Ends . . . . . . . . . . . . . . . . . . .378 Other Possibilities . . . . . . . . . . . . . .379 Simple Blackjack . . . . . . . . . . . . . . . . .379 Project Goal . . . . . . . . . . . . . . . . . .379 Approach . . . . . . . . . . . . . . . . . . . .380 Preparing the Movie . . . . . . . . . . . . .380 Writing the Code . . . . . . . . . . . . . . .381 Loose Ends . . . . . . . . . . . . . . . . . . .387 Other Possibilities . . . . . . . . . . . . . .387 Pyramid Solitaire . . . . . . . . . . . . . . . . .388 Project Goal . . . . . . . . . . . . . . . . . .389 Approach . . . . . . . . . . . . . . . . . . . .389 Preparing the Movie . . . . . . . . . . . . .390 Writing the Code . . . . . . . . . . . . . . .390 Loose Ends . . . . . . . . . . . . . . . . . . .396 Other Possibilities . . . . . . . . . . . . . .396 16 Arcade Games . . . . . . . . . . . . . . .397 Space Combat . . . . . . . . . . . . . . . . . .398 Project Goal . . . . . . . . . . . . . . . . . .398 Approach . . . . . . . . . . . . . . . . . . . .399 Preparing the Movie . . . . . . . . . . . . .399 Writing the Code . . . . . . . . . . . . . . .400 Loose Ends . . . . . . . . . . . . . . . . . . .405 Other Possibilities . . . . . . . . . . . . . .405 Space Rocks . . . . . . . . . . . . . . . . . . . .406 Project Goal . . . . . . . . . . . . . . . . . .406 Preparing the Movie . . . . . . . . . . . . .407 Writing the Code . . . . . . . . . . . . . . .407 Loose Ends . . . . . . . . . . . . . . . . . . .415 Other Possibilities . . . . . . . . . . . . . .415 Maze Chase . . . . . . . . . . . . . . . . . . . .416 Project Goal . . . . . . . . . . . . . . . . . .416 Preparing the Movie . . . . . . . . . . . . .416 Writing the Code . . . . . . . . . . . . . . .417 Loose Ends . . . . . . . . . . . . . . . . . . .424 Other Possibilities . . . . . . . . . . . . . .424 Moon Lander . . . . . . . . . . . . . . . . . . .425 Project Goal . . . . . . . . . . . . . . . . . .425 Preparing the Movie . . . . . . . . . . . . .425 Writing the Code . . . . . . . . . . . . . . .427 xiv Macromedia Flash MX ActionScript for Fun & Games 00 0789727994 fm 6/20/02 2:37 PM Page xiv Loose Ends . . . . . . . . . . . . . . . . . . .432 Other Possibilities . . . . . . . . . . . . . .432 Platform Scroller . . . . . . . . . . . . . . . . .432 Project Goal . . . . . . . . . . . . . . . . . .433 Approach . . . . . . . . . . . . . . . . . . . .433 Preparing the Movie . . . . . . . . . . . . .434 Writing the Code . . . . . . . . . . . . . . .435 Loose Ends . . . . . . . . . . . . . . . . . . .443 Other Possibilities . . . . . . . . . . . . . .443 17 Advanced Techniques . . . . . . . . . .445 Performance and Optimization . . . . . . .446 Using Alternatives . . . . . . . . . . . . . .446 Benchmarking . . . . . . . . . . . . . . . . .446 Choosing the Best Alternative . . . . . .448 Benchmarking ActionScript . . . . . . . .449 Loader Screens . . . . . . . . . . . . . . . . . .451 Building a Loader . . . . . . . . . . . . . .451 A More Advanced Loader . . . . . . . . .454 Other Types of Loaders . . . . . . . . . .455 Copy Protection . . . . . . . . . . . . . . . . .456 How and Why Games Are Stolen . . .456 Preventing Your Game from Running Elsewhere . . . . . . . . . . . . .457 How to Get Around Copy Protection . . . . . . . . . . . . . . . . . . . .458 More Methods of Protecting Yourself . . . . . . . . . . . . . . . . . . . . .459 High Score Boards . . . . . . . . . . . . . . .459 How High Score Boards Work . . . . .459 The Perl Programs . . . . . . . . . . . . . .460 Demonstration High Score Movie . . .464 Implementing High Scores in a Game . . . . . . . . . . . . . . . . . . . . . . .466 High Score Board Issues . . . . . . . . . .468 Testing Flash Player Versions . . . . . . . . .469 Getting the Player Version . . . . . . . .469 Requiring Versions . . . . . . . . . . . . . .470 Flash 6 Player Capabilities . . . . . . . .472 A Internet Resources for the Flash Developer . . . . . . . . . . . . . .475 B The History of Games . . . . . . . . . .477 Index . . . . . . . . . . . . . . . . . . . . . . . .487