Friday, March 13, 2009

CHAPTER 2 - Test the movie

“Test early and test often” is a mantra for Web developers. The sooner you test your movie, the easier it is to determine the cause of unexpected results. It’s a good idea to save multiple versions of your file using sequential names—for example, mypuzzle1.fla, mypuzzle2.fla, and so on, as you’ve been doing in this tutorial. This way, the highest numbered file is always the newest and it’s easy to revert to an earlier version.

As you learned in the Introduction to Flash MX Tutorial, the Flash authoring tool includes a version of the Flash Player that lets you test your movie at any point during authoring by choosing Control > Test Movie. This version of the Flash Player has several commands and tools to help you troubleshoot your movie.

The most common reason for unexpected results in a Flash movie is an incorrect path to a variable, function, object, or movie clip. This can cause a variable to contain the wrong value, prevent a function from being called, or prevent a movie clip from playing correctly.

The trace action allows you to write notes and expressions in your scripts whose results are sent to a window called the Output window.

Now you’ll add a trace action to test if a function was called successfully.

Note: Flash also includes a Debugger, which lets you examine the values of global and local variables, including when they change as the movie plays. Additionally, with the Debugger you can use breakpoints to stop the movie and test ActionScript line by line. For more information, see “Using the Debugger” under Help > Using Flash.

1 Choose File > Open and choose the version of the mypuzzle.fla file that you last saved.

Note: You can also browse to your Flash MX application folder and open Tutorials/ActionScript/Finished/ puzzle8.fla. If you do use the puzzle8.fla file, save the file with a new name in your My_Puzzle folder to maintain an unadulterated version of the original file.

When the user clicks the OK button in the SWF movie, the puzzle pieces should scramble. You can use a trace action to test if the Scramble function is being called.

2 In the Actions layer in the Timeline, select Frame 1 and open the Actions panel.

3 In the Script pane, scroll to and select line 18, the commented line that says // enter trace action here.

4 In the Actions toolbox, double-click the trace action from the Actions > Miscellaneous Actions category.

5 Type Scramble function has been called in the Message text box. You are placing this message within the Scramble function. 6 Save your document, then choose Control > Test Movie.


7 Click the OK button in the SWF movie.

The Output window appears, which traces events in your movie. Enlarge the window, as necessary, to read the messages. The message Scramble function has been called appears in the Output window.




















If the message did not appear, your next step would be to determine the reason why. The most likely reason is that you specified an incorrect path to the function.

8 Close the Output window and SWF file and return to authoring mode.

9 Choose File > Save As and enter a new filename. Use a consecutive naming scheme so you can revert to earlier versions of the file, if necessary.

You’ve made great progress in learning ActionScript!




.
.
==============================================
.
Contents
Trademarks
CHAPTER 1 - Introduction to Flash MX Tutorial
CHAPTER 1 - What you should know
CHAPTER 1 - View the completed movie
CHAPTER 1 - Analyze the stiletto.fla file
CHAPTER 1 - Define properties for a new document and create a ...
CHAPTER 1 - Create and mask vector art
CHAPTER 1 - Tween bitmap effects within a movie cl...
CHAPTER 1 - Load dynamic text at runtime
CHAPTER 1 - Add animation and navigation to button...
CHAPTER 1 - Add streaming and event sounds
CHAPTER 1 - Organize your Library panel
CHAPTER 1 - Test download performance and publish ...
CHAPTER 1 - The next steps
.
CHAPTER 2 - Introduction to ActionScript Tutorial
CHAPTER 2 - View a completed movie
CHAPTER 2 - Initialize the movie
CHAPTER 2 - Save and retrieve information
CHAPTER 2 - Display information in a dynamic text ...
CHAPTER 2 - Write an expression
CHAPTER 2 - Control the flow ofthe movie
CHAPTER 2 - Create commands and reuse code
CHAPTER 2 - Use a built-in object
CHAPTER 2 - Test the movie
CHAPTER 2 - The next steps
.
CHAPTER 3 - Introduction to Components Tutorial
CHAPTER 3 - Types of components
CHAPTER 3 - View the completed form
CHAPTER 3 - Create a form
CHAPTER 3 - The next steps
.
==============================================