Introduction to ActionScript Tutorial > Test the movie |  |

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.

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!