Flash11: ActionScript 3: Using the Code Snippets Panel

CS5 Introduces a new feature that provides instant access to regularly used code snippets, all filed in an easy to use and access panel.

Accessing the Panel
The Code snippets panel is located in the Windows menu on the toolbar. Clicking Code Snippets will float the snippets panel. Keep it floated or drag to drop in or next to any existing panel or dock. It is quite useful to have this docked in under the library.

Using the Code
You now have an easily access resource containing a number of ready to use and adapt ActionScript snippets. Create a small square on the stage using the shape tool. Make sure it is selected, then open the snippets panel and open the Event Handlers folder. Double click on Mouse Click Event. You will get a message telling your shape will need to be converted to a movie clip before the code snippet can be applied. Flash 11 automatically does this for you each time you apply a snippet, so you can tick the box "Don't show Again" and Click OK.



The Actions panel will open and you will presented with ready made script set to go. The .addEventListener and MouseEvent function are added ready for customizing. It would be a good idea at this stage to give your object a unique name and reflect that in the code (to prevent meaningless movieClip_2, movieClip_3 scenarios as your project develops.), and likewise your function name.



This is just one of the new and useful features in the latest Adobe Release.

Resources
Video Tutorials at Adobe TV

Code Snippets at Adobe