Code Snippets are pieces of predefined code that can be reused, saved in the "Code Snippets" panel. They are organized on cathegories and functions, such as: "Animation", "Timeline Navigation", and others.
You can open this panel from the Window -> Code Snippets menu, or the button "Code Snippets" found in the Actions panel (as you can see in the following image).
Flash has a few functions /codes saved in "Code Snippets". For example, to make a button execute a jump to a certain frame, instead of writing the whole code (with the necessary event and function), you can add it directly from the "Code Snippets" panel, being saved in the "Timeline Navigation" catalogue, with the name "Click to Go to Frame and Play".
To add a code-snippet into your script, double-click on its name, select it and click the button "Add to current Frame".
• Flash has in "Code Snippets" some of the most used functions for working with ActionScript. To learn about them you must browse their list, the name with which they are saved also explains their role.
Besides these predefined functions included in Adobe Flash, you can also add your own pieces of code to be stored in "Code Snippets", useful when you usually use a same code expression, functions or any code.
• To add your own code in the "Code Snippets" panel, you must click on the panel's options menu (upper-right)and choose the option Create New Code Snippet, Flash will open a window as the one in the following image.
- At Title you must write the name (as suggestive as possible) that will appear for that code added in "Code Snippets".
- The description that is writte at Tooltip will appear when the mouse is positioned over the name stored in the panel.
- You write the ActionScript code in the text area, Code. If a certain piece of the code is already selected in the "Actions panel", use Auto-fill button to add the selected code in the "Code" area.
- After pressing the OK button, the respective code is added with the name specified at "Title" in a folder named "Custom" (created automatically by Flash).
Predefined codes as well as those added in "Code Snippets" are stored in a XML file.
- To re-edit a Code Snippet, right-click on its name and choose Edit Code Snippets XML. This will open the XML file with all the predefined codes from the panel. Then, you must find the code in that file (with "Ctrl+F") and edit it. Then click File -> Save.
- The option "Copy to Clipboard" (which appers when you right-click on a code-snippet) copies the respective code in memory, and then it can be added (with Paste) in the "Actions panel".
- With "Delete Code Snippet" the respective code will be deleted from the panel.
- The XML file with all the codes stored in "Code Snippets" can be exported with the option "Export Code Snippets XML".
- With "Reset to Default XML" the "Code Snippets" panel is restored to it's initial predefined codes.