Home / Articles / Adobe Flash / An Introduction to Using Code Snippets in Flash CS5

An Introduction to Using Code Snippets in Flash CS5

Article Description

Chris Florio, contributor to ActionScript 3.0 for Flash Professional CS5 Classroom in a Book, introduces the new Code Snippets feature in Flash CS5. This article shows how to add rich interactivity to Flash projects without writing any code, as well as how to modify the code snippets that Flash creates to customize your interactivity without a mastery of programming syntax.
Creating your First Code Snippet

Creating your First Code Snippet

If you tested this movie now (Control > Test Movie > Test), there would be no interactivity in the file, and nothing would happen when you clicked on the various objects. The first code snippet you will add will allow the user to navigate to each of the three movie clips that have tabbed pages. You will do this with a code snippet called “Bring Object to Front,” which will bring any object to the front of the Flash display list when it is clicked.

  1. In the Code Snippets panel, open the directory named Actions (Figure 2).
  2. Double-click on the code snippet named “Bring Object to Front.” Notice that an Actions layer was added to your timeline and that quite a bit of ActionScript was written in the Actions panel. This is the code that will make any selected object come to the foreground.
  3. Test the movie (Control > Test Movie > Test), and click on each of the tabs sequentially. The movie clip that is selected should appear in front of the others.
  4. Close the codesnippets_start.swf file to leave the Flash testing environment and return to the authoring environment.
3. Setting a Custom Cursor | Next Section Previous Section