| Syllabus
--------------------- --------------------- --------------------- --------------------- ---------------------
|
Art 444 Lecture Notes
Note: The following tutorials are variations of the Flash movie tutorials found in Chapter 7 of the Flash MX 2004 Advanced Visual QuickPro Guide by Russell Chun. Please refer to this text for more advanced scripting possibities. THESE EXANPLES USE ACTION SCRIPT 2.0. NOTE: All scripts below involve creating an Action layer for your script. All script go in this layer. Create
a draggable movie clip in Flash MX
2004 (see Chapter 7, pp. 284-287) Here is how your script should look: eyes_mc.onPress
= function() { Note: 'eyes_mc' is the instance name of the movieclip you wish to drag. Define
a droptarget for a draggable movie clip (see
in Chapter 7, p.308) Example: eyes_mc.onPress
= function() { NOTE: this._visible = false; script makes the 'eyes_mc' invisible when dropped on the 'potato' drop target. See Chapter 7, pp.288-291 for information on setting the movie-clip properties. 1) Follow
the steps above to create a draggable movie clip with a drop target. Example: eyes_mc.onPress
= function() { Variation: Another technique to create a bounce-back effect is by capturing the position of the MC before it is dragged. Here's the code: eyes_mc.onPress
= function() { Start playback of a movieclip's timeline or the main(_root) timeline when the movie clip has been dragged to the correct drop target using: trashcanlid_mc.play(); This script causes the movieclip instance titled, "trashcanlid_mc" to begin playback from the first frame of the clip (a stop action is placed on its first frame). In this example, the can lid closes. Variations include nextFrame(); This script takes you to the next frame of a timeline. prevFrame(); This script takes you to the previous frame of a timeline. _root.gotoAndPlay("frame label"); takes you to a named frame label on the movie's main timelime. Example: paper.onPress
= function() { It is important to use Frame labels instead of referring to the frame number at all times when jumping to a new frame in your movie. Add a frame label by selecting the frame in the timeline and entering a name for your label in the Frame Properties panel. Note: If you need to jump to a new frame of the main timeline you will need to use _root BEFORE gotoAndPlay("frame label"); Example: paper.onRelease = function() { Attaching a movie clip symbol from the Library (see in Chapter 7, pp. 314-315 ):In the script below, when you release the "appleButton" a MC named "apple" will attach itself to a parent MC called "plate." The "apple" MC is exported from the Library by linking the MC for export to action script. Example: appleButton.onRelease
= function() { Here are the steps: 1) Create
two movies clips. The first one will be the parent MC that the
other MC will attach to.
Attach a sound event with the droptarget property (see in Chapter 8, pp. 354-361):This script plays a sound once the draggable has hit the droptarget. You will need to make the attached sound exportable to the root timeline by selecting the sound in the Library and selecting "Linkage" from the pull-down menu. Give the sound an identifier name (I've named the sounds used below as "cheer" and "boo"). Check the "Export for Action script" and enter the following code into your action layer script: Example: mySound = new Sound(); eyes_mc.onPress
= function() { eyes_mc.onRelease
= function() { Note: mySound = new Sound(); instantiates the Sound object. I only needs to be used once if you are attaching the sound object to different MCs. "0" sets the secondOffset, meaning that your sound will start 10 seconds into its timeline if entered. The second number correlates to how many times you wish to loop the sound. |
|||
Back to top of page | School of Art, Design and Art History | SDSU Main