Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Code snippets give you an excellent starting point when writing code, by giving you access to dozens of useful, prewritten blocks of ActionScript. To access the Code Snippets panel, you can click the Code Snippets button in the top-right of the Actions panel, or go to Window > Code Snippets. Now, you're probably already familiar with the Code Snippets panel, so I'm just going to do a quick review. The snippets are organized in categories: regular actions, actions for timeline navigation, for animation, loading and unloading files, et cetera.
Let's say I want to stop the Timeline. I could expand the Timeline Navigation, and double-click stop at this frame. In the Actions panel, you'll see the stop action is added. It says 'stop,' and there's parentheses, and then as semicolon, and there is a comment. You can tell it's a comment because it's gray. Remember that multiline comments start with a forward slash and an asterisk and then end with asterisk forward slash. This comment explains what the code does. Now, you've probably already done this before, if you've ever used the Code Snippets panel.
But another thing you can do with the Code Snippets panel, if you're an advanced user, is create your own code snippets. Let's go back to the Code Snippets panel and see how to do this. To create your own snippet, click the Gear icon at the top-right of the Code Snippets panel. Then choose Create New Code Snippet. Give your code snippet a Title. Give your code snippet a tooltip.
You can autofill from code that's already selected in the Actions panel if you want, or you can simply write your code in the Code area. This code doesn't really do anything, so you don't need to copy it down if you don't want to. Note that you can also check this box to automatically replace instance_name_here when you're applying the code snippet. You may have seen an example of that when you, say select a button, and then use a code snippet to make that link to a web site.
That's what you're essentially doing here. To create the code snippet that does that, you simply type instance_name_here, and Flash will automatically replace that code with the correct instance name when you select it on the stage and apply the code snippet. Keep in mind that if you didn't understand that, it's no big deal. That's something that you're going to understand more about when you learn more about ActionScript. So I'll click OK to create the code snippet, and then you can see my example snippet in the Custom section. So, I'm going to apply it into my code by double-clicking it, and there it is right there.
So if you ever find yourself constantly writing the exact same block of code, see if you can find it prewritten in the Code Snippets panel. If it's not there, you can always add it yourself, so you can save time when creating your projects.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 102019 Viewers
61 Video lessons · 88736 Viewers
71 Video lessons · 72559 Viewers
56 Video lessons · 104207 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.