Discussion of Flash text/string operations for creating two games: Hangman and Word Search. References Gary Rosenzweig's book: ActionSccipt 3.0 Game Programming University and companion web site http://flashgameu.com/
2. AGENDA
Syllabus updates
Project updates - presentations
Strings in Flash
Hangman Game
Word Search Game
Sunday, April 5, 2009 2
3. SYLLABUS
Three weeks until presentations - April 27
Final Flash discussion next week -
Trivia and Quiz Games
No class meeting May 4 - Reflection Paper due
Sunday, April 5, 2009 3
4. PROJECTS
Fab C - Recycling Maze Game
Fantastic Four - Geography Game
Flash Sharks - “Let’s Play Math!” Game
Funky Flash - “Algebra: It’s an Everyday Thing” Quiz
Game
Worry Warts - Recycling Instructional Game
Sunday, April 5, 2009 4
5. PRESENTATIONS APRIL 27
15-20 Minutes including time for questions
Professional pitch, rehearsed, ppt optional, demo
Deliverable will be a CD (no need for binder)
Flash, SWF, and related files
Project Documentation: Design Document; Project
Plan; prototype/storyboard; pilot report;
presentation materials
Sunday, April 5, 2009 5
6. STRINGS IN FLASH
Think of a string as an array of characters
Strings are a very useful engagement design element
for creating cognitive challenge with verbal and visual
information (examples: word search; sodoku;
vocabulary development, etc.)
Flash provides a rich set of functions for managing
strings--summarized by Rosenzweig on p 302
charAt join slice toLowerCase
charCodeAt lastIndexOf split toUpperCase
concat match string
fromCharCode replace substr
indexOf search substring
Sunday, April 5, 2009 6
7. TEXT FORMATTING
Text formatting may be applied by creating style
sheets or TextFormat objects in ActionScript
Style sheets are applied to HTML text whereas
TextFormat objects are used with text fields in Flash
Two methods are available for creating TextObjects:
Inline and formal
TextFormat objects are usually created just before a
TextField
Sunday, April 5, 2009 7
8. FORMATTING TEXTOBJECTS
Flash provides a set of properties for formatting
text--summarized by Rosenzweig on p 304
align font leftMargin target
blockIndent indent letterSpacing underline
bold italic rightMargin url
bullet kerning size
color leading tabStops
Sunday, April 5, 2009 8
9. CREATING TEXTFIELD OBJECTS
Creating a TextField is similar to creating a Sprite
Both are display objects
Both can be added to other Sprites and Movie clips with addChild
var myTextField:TextField = new TextField();
addChild(myTextField);
Formats are assigned to text fields using two
methods:
defaultTextFormat - generally used with text fields in games
myTextField.defaultTextFormat = letterFormat;
setTextFormat - allows specification of start/end characters for
formatting
myTextField.setTextFormat(letterFormat);
Sunday, April 5, 2009 9
10. TEXTFIELD PROPERTIES
Flash provides a set of properties for managing text
fields--summarized by Rosenzweig on p 305-6
autoSize defaultTextFormat textColor
background embedFonts type
backgroundColor multiline wordWrap
border selectable
borderColor text
NOTE: to embed fonts in your project requires that you
first import the font using the library dropdown menu
and then set the lingag properties to export the font to
ActionScript (discussed on p 306 and in Ch 7)
Sunday, April 5, 2009 10
11. ANIMATED TEXT EXAMPLE
Rosenzweig provides an animated text example to
demonstrate the string concepts discussed with a bit
of panache
TextFly.fla
TextFly.as
If you have extra time in your project, this code could
be reused to animate the title on your intro frame
Sunday, April 5, 2009 11
12. HANGMAN GAME
‘Relatively’ simple game, take on 19th century game
minus the gallows
Consists of guessing the letters to complete a phrase
Number of wrong answers tied to number of frames
of movie clip; although game play continues until user
quits the Flash app
Sunday, April 5, 2009 12
13. HANGMAN GAME ELEMENTS
Single frame with one movie clip in the library
All game elements and logic stored in document class
library--Hangman.as
Sunday, April 5, 2009 13
14. HANGMAN GAME MODS
Easily change phrase in AS file or randomly generate a
list of phrases using an array
Include an intro, game, and scoring screen to provide
setup and scoring
End game when number of tries exceeds number of
frames in movie clip
Sunday, April 5, 2009 14
15. WORD SEARCH GAME
This game is obviously more complex, follows 3-
frame structure: intro; play; gameover
All game logic is in a single document class
WordSearch.as linked to WordSearch.fla
Searches are horizontal, vertical, and diaganol
Words are removed from list when located
Sunday, April 5, 2009 15
16. WORD SEARCH MODS
Easily modifiable to any subject, simply change the list
of words
Words could also be read from an external (XML) file
for even greater flexibility
Could add a timer
Grid size can be reduced for younger audiences
Sunday, April 5, 2009 16