Date: Mon, 11 Feb 2008 17:14:12 -0600 (CST) From: Mark Jacobson To: 810-088-09-spring@uni.edu Subject: [810-088-09-SPRING] Quiz Two Wednesday... Hi Flash students, On Wednesday, we will have quiz two. *** Practice question #1: Write the Actionscript code for a STOP button that would cause the animation of the main timeline to pause or stop. Answer: on (release) { stop(); <---- is the ; required? Yes! } *** Practice question #2: Write the ActionScript code to start up an animation that was stopped. Assume the actionscript code is for a BUTTON. on (release) { play(); <----- are the ()s required? Yes! } *** Practice question #3: How do you quickly get to the ActionScript code window, or just as quickly hide that window when you need to get it out of the way again? (What Keystroke or key is the shortcut?) Besides the words release and play(); or stop(); and on ------- ------- ------- -- what other syntax elements are required and always found in programming for a BUTTON release event in ActionScript 2.0? You need a pair of parenteses, i.e. ( and ). Where do they go? After the on (someMouseEvent) i.e. on (release) what do you need? Brace yourself for this, you need braces, curly braces. { } are the package for the statements to be performed when the used releases the mouse button. on ( release ) { <------------ opening brace whatever things are to be done go here, between the braces... ActionScript statements like play(); stop(); this.theCar.rearWheel.play(); gotoAndPlay(1); gotoAndStop(10); getURL("http://www.uni.edu"), etc. } <------------ closing brace A more concrete example, from today's handout on Cars with RotatingWheel objects that go round and round. on ( release ) { <------------ opening brace stop(); this.theCar.frontTire.stop(); this.theCar.backTire.stop(); } <------------ closing brace So basically, all you have to remember to be able to write a very simple actionscript for a button is: on starts if off. on is a keyword in Flash ActionScript. -- 2 ()s are needed, or rather one pair of ()s is needed. 2 {} are needed, to package all of the statements that are to be performed when the button has a mouse RELEASEd on it. Between the braces are statements, of which you only have to know two for quiz two. play(); and stop(); ------- ------- 7 characters each in play(); and in stop(); 2 statements, 14 characters... play(); stop(); 2/14 is Valentine's Day, so how is that for a way to focus and help you remember the code. ------- Between the ()s is just one word, the word release ------- on (release) { statements ending in semicolons, most of which always end with ();, like play(); stop(); } release means release of the mouse button, which is when you let it up on the stopButton or the goButton or the stopWheelsOnlyButton. on (press) { } could also be used instead of on (release) { } *** Practice question #4: Explain the difference between a mask layer and a masked layer. T or F What you draw on the mask layer will hide whatever is underneath it in the masked layer. -------------------------------------------------------------------- This is enough of a study guide for quiz two. See you on Wednesday. Be sure to review http://www.cs.uni.edu/~jacobson/flash/ often. There are lots of new links and material up there. Mark