Flash Interactivity Tasks
Buttons:
- Simple multi-state button:
- create a new button Symbol
- make key frames for each state, and draw a different design for each
keyframe.
- put button on the stage from Library
- test!
- simple multi-state button with instances:
- create new graphic symbol
- draw button design
- close symbol
- create new button symbol
- drag graphic into frame 1
- copy 1st keyframe for other states
- select frame, graphic and change Tint or Alpha in properties inspector
- repeat for each state
- close button, put button on main timeline, test
- animated multi-state button
- create new movie clip symbol
- draw sequence of keyframes to create animation
- close movie clip (MC)
- repeat steps 1-3 two more times
- create new button symbol
- drag MC from library - one MC per state of button
- put button on main stage, test
- sound on button:
- go to findsounds.com , download
sound files
- import sounds into flash
- open button symbol, add new layer, name it sounds
- add keyframes for each frame of new layer
- select keyframe, go to Properties Inspector, select sound
- close button, test
- button controlling movie clip
- create new MC
- create animated sequence of frames in MC
- create new layer
- select 1st frame of new layer
- add action: Stop();
- add keyframe on last frame
- add action on last keyframe: gotoAndPlay(2);
- close MC, add to main stage, give it an instance name in properties
inspector
- select one of your buttons, add action: on (press){
- click target button, select your MC, add script yourmovieclip.gotoAndPlay(2);}
- select another one of your buttons, do as above, only gotoAndStop(1);
- test your buttons!
- Invisible button, invisible movie:
- create a new movie clip
- leave 1st frame as Blank keyframe
- create animated sequence starting on frame 2
- add stop action on frame 1, as done above
- close MC, create new button
- add keyframe on Hit frame, draw shape, leave other frames blank
- put both symbols on stage, give MC an instance name
- select button, add script: on (rollOver){
- target your MC, do yourclip.gotoAndPlay(2);}
- do on (rollOut){
- target MC, do yourclip.gotoAndPlay(1);}
- Sounds off button:
- import sounds into flash
- add new layer for each sound
- add Sound to keyframes of various sound layers
- select one of your buttons that has no script, or make a new button,
and add script:
- on (Press){ stopAllSounds();}
- Button to play a sound/stop a sound:
- create a new MC
- put keyframes on frames 1 and 2
- using Property Inspector, set sound to STOP on frame 1, PLAY on frame
2
- add stop action on frame 1
- put MC on stage, give instance name
- make 2 buttons, play and stop.
- on play button, make script to play MC from frame 2 (as done above)
- on stop button, make script to play MC from frame 1
- Button to play a video:
- import video
- edit/adjust as desired
- video will import into a new movie clip. let flash adust the length
of the MC to the length of the video
- open video MC, add stop script to 1st frame
- put MC on stage, give instance name
- make button, have it play MC from frame 2
- if you don't want 1st frame of video to show before play, open video
MC and move video so it starts on frame 2.
- Make a draggable button (works for a MC too):
- create multi-state button (as above)
- make a new MC - put the button into the MC
- put the MC on the stage (if you try to do this with a button directly
on the stage, the whole stage will be draggable!)
- Open the MC, select the button, and add the following script:
- on (press){
startDrag(this);
}
on (release){
stopDrag();
}
- Close MC and test movie!
- Test to see if your draggable button intersects another button or MC:
- Create draggable button as above
- Create another MC. Give it two different frames of graphics. Put a
stop(); on frame 1 of the MC. Close MC and put on stage.
- Give the button and MC instance names (ie "but" and "mc")
- On your main timeline, add a keyframe on frame 2. Add a script to frame
2 that says:
gotoAndPlay(1);
This sets up a short loop.
- Add a script to frame 1. (Because we keep looping to frame 1, this
script will be run every 2 frames!)
if(_root.but.hitTest(_root.mc)){
_root.mc.gotoAndStop(2);
}
This checks to see if the "but" instance is intersecting the "mc" instance,
and, if it is, sends the MC to its 2nd frame.
- How to use a variable to track how many times the user has clicked something:
- create a movie with 2 scenes, stops on the 1st frame of each scene,
and a button in the 1st scene.
- add a script on the 1st frame that says:
myVariable = 0;
//declares variable and initializes it to value 0)
- Add a script to the button:
on (press){
myVariable++
//adds 1 to the value of variable
trace("the number of clicks is " + myVariable);
//puts the value of the variable in the output window
if (myVariable >= 5){
gotoAndPlay("Scene 2", 1);}
//checks if variable is 5, goes to scene 2 if so
}