Introduction to Flash and Actionscript
S3 - Using Buttons, Keyboard, and HitTest
1 - Creating a Basic Button
To test when the button has been clicked we use an EventListener.
EventListeners wait until something happens and then run the code that is associated with the action.
Add the following code to the actions layer.
Using Buttons to Control Animations
Tutorial 2 - Start and Stop Buttons
Create 2 Buttons one for Start and one for Stop
Create a tween to move an object left and right. (Code or Tween)
If you are using a new Scene instead of a new file at the end of you tween return to frame 1
you are using a built in Tween
If you are using a built in Tween
are using code
If you are using code
To stop the Tween use
To stop the Tween use
1 - Moving/Resizing objects using Buttons
Assignment 1 - Moving/Resizing objects using Buttons
from student work
Example from student work
a) Move a Symbol up and down using arrow buttons
b) Add left and right buttons
c) Resize a Symbol
d) Rotate a Symbol
Assignment 2 - Next and Previous
Assignment #3 - Pacman Menu Screen
Create a new menu scene in your pacman game. This will be between your morphing titles and your first simulation. Include the following buttons:
1. Tween Simulation
2. Code Simulation
3. Play the Game
should return to the menu when complete
Assignment #4 - Play Pacman using Keyboard Commands
- create a new scene where pacman is controlled by the user using the keyboard. In order to hittest the walls you will need to draw the maze yourself. Each wall will need a different instance name.
- at the end of the scene display ending scene with the option to play again or return to the main menu
Below is an example of KeyboardEvent.Key_Down works, you will have to rotate your images in each function
Import your Keyboard Events at the top of the first frame in your imports section
To avoid having to click on the stage
//focus the screen
Assignment 5 - Ghosts and Event Listeners
We will move the ghosts using EventListeners and Functions so that we can collide with them later.
To Move to a New Scene
Tutorial 3 - Drag and Drop
Create 2 squares and convert them to movie clips.
Type in the code below and test
Document each section of code so that I know you understand what is happening.
This tutorial will be marked for documentation only
Assignment 6 - Pacman Collisions
Delete the dots when pacman hits them.
End the game when pacman hits a ghost. (You will need to have the last ghost event listener call the first)
Quit will Only work when the game has been compiled not in Testing Mode
Above and Beyond
For both of these you will need to use a variable. See next section! Hints below but I will not solve this for you. (That is why it is above and beyond)
ICS3C students only need to do 1 of the items below. Bonus if you do both. Also I will help if you need an explanation.
1. Add a scoring system
Use a printScore function to initialize score and print it in a text box
// Initialize score variable
On your dots hittests add one to the score
// to add to score
To exit a a certain score put an if condition in the printScore function
// add an if to your printScore function
remove the event listener
2. Hittest your walls in you hittest function, so that pacman cannot travel through them.
hit = true
else if (pacman_mc.hitTestObjec(wall2_mc))
hit = true
// Keep going for all your walls
// last condition is an else
if no wall is hit
hit = false
At the start of your program initialize hit
if (hit == false)
// All your normal commands
if (hit == true)
// move in opposite direction (incease number slightly)
Embed all tutorials, assignments, and code.
Attach your .swf files
Link to your .fla files
Copy the Evaluation Sheet to your google drive and post the link at the top of your webpage.