Programming games
Flash concepts. Coin toss.Filezilla: upload your project(s)
Homework: Enjoy Spring Break.
Flash
• Environment for creating and testing Flash application– including writing code and creating graphics
• When you are done, you PUBLISH to produce a pair of files: .swf and .html.
• Many features in Flash: more than we will do.
ActionScript 3.0.
• We will NOT do ActionScript 2.0.• Significant changes in the language.
Flash features
• Stage• Timeline
– frames– layers
• Properties panel• Tool panel
• Window/Actions: where you write code for a layer of a frame in a timeline.
Flash object• Movie clip
– Timeline: 1 to any number of frames– code in any frame– Note: many of our movie clip symbols will have just
one frame.• Button
– 4 frames: up, over, down, hit• Graphics• We mainly will create movie clip symbols and
place instances of them on the Stage at specific frames.
Coin toss• Create 2 movie clip symbols and move instances to the
Stage and NAME INSTANCES.– head– tail
• Look at Window/common libraries/buttons and get a button– alter this button to display FLIP.– name the button instance
• Write code in the [only] frame of the main movie (Scene 1) to – set up event handling for hitting the button– simulating random coin toss by making either head or tail visible
and the other not visible.
Techniques
• Use rectangle/oval tool and keep shift key down to make a circle.
• In Library panel, right click on head, duplicate, rename tail to get same size.
• Use segmentation to erase parts…• Change magnification to make larger to
ease drawing.
NAME things
• Move instances of symbols to Stage.• You need to give the instances names in
order to reference them in ActionScript.
• While selected, in Properties panel, give a name.– It can be the same as the movie clip symbol
name. In some applications, you may have more than one.
Buttons
• I will show you 3 ways to make buttons. – common library– do it yourself (rock paper scissors)– components
• This is Common Library way. Need to change Enter to Flip.
Change symbol in Library
Changing text…• Need to unlock the text layer• Pick up T tool • make change
• return to Scene 1
Notice
• When you change something in the Library, all instances of it change on the Stage.
• Need to give the button instance on Stage a name: flipbtn.
Add coding
• Click off of any object so nothing is selected.
• Windows/Actions• Write code
Testing
• Go to Control/Test movie/In Flash Professional
• When it works, File/Save As
Improvement
• Keep track of counts of heads and tails.• Create 2 TLF read only and 2 selectable
text fields• Expand Character panel to change size
and font and other features.• Use x and y in Properties panel to line up.• Name the selectable text fields.• Modify code.
2 + 2 text fields
Changing code
• The text in the text field must be changed to a number before adding 1 to it and then changed back to text.
• The text is referenced using the name of the text field with .text
Homework
• [Finish and show coin toss with counts. Add anything else you want.]
• Enjoy break!
• You can do tutorials, practice drawing.• You can look ahead to rock-paper-
scissors, Bo the barking dog, etc.