Start learning with our library of video tutorials taught by experts. Get started

Flash Professional CS5 New Features

Creating code snippets


From:

Flash Professional CS5 New Features

with Todd Perkins

Video: Creating code snippets

With the Code Snippets panel, you can also create custom code snippets. We'll take a look at an example in this movie. One of the snippets, in the Code Snippets panel, is for keyboard control of an object. So you can use that in something like a game, to move an object around. However, the functionality is a little bit limited. I added some functionality to the keyboard control. In this movie, we'll look at making that into a custom code snippet. Let's take a look at the code I have in the Actions panel. Here, I have all the code for keyboard control.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Flash Professional CS5 New Features
1h 20m Intermediate Apr 12, 2010

Viewers: in countries Watching now:

In Flash CS5 New Features, author Todd Perkins demonstrates key changes in the CS5 release of Adobe's interactive design and animation software. This course covers enhanced ActionScript features, including code snippets and error handling improvements, new publishing options for Adobe AIR, Illustrator, Photoshop, and Flash Builder integration, and the new Text Layout Framework for detailed text editing. Exercise files are included with the course.

Topics include:
  • Comparing Flash CS4 and Flash CS5
  • Inserting modifiable cue points for video in Flash
  • Editing text in the Text Layout Framework
  • Embedding fonts
  • Creating and editing ActionScript code snippets
  • Performing roundtrip editing between Photoshop and Flash
  • Exporting FXG files for use in Flash Catalyst
  • Integrating with Flash Builder
Subject:
Web
Software:
Flash Professional
Author:
Todd Perkins

Creating code snippets

With the Code Snippets panel, you can also create custom code snippets. We'll take a look at an example in this movie. One of the snippets, in the Code Snippets panel, is for keyboard control of an object. So you can use that in something like a game, to move an object around. However, the functionality is a little bit limited. I added some functionality to the keyboard control. In this movie, we'll look at making that into a custom code snippet. Let's take a look at the code I have in the Actions panel. Here, I have all the code for keyboard control.

At the very bottom, I'm adjusting the x and y position of an object, and the object is instance_name_here. Note that it is red, and that's significant. We'll take a look at that in just a minute. Wherever you want to have the instance name of an object that's going to be manipulated, you need to put instance_ name_here inside of the Actions panel and make sure that it's red. That means you typed it correctly. So once you have your code, select it all, using your computer's keyboard shortcut, and then you can open up the Code Snippets panel.

I like to open it up directly from the Actions panel. To create a custom snippet, all you have to do is go to the Options area of the panel, toward the top-right, and then choose Create New Code Snippet. Here, you can choose a Title and a tooltip and choose whether to use code selected in the Actions panel. I'll click Auto-fill to do that. For the Title, I'll call this Advanced Keyboard Control, and then I'll type for the tooltip, 'Control an object with the keyboard.

Change speed variable to update speed.' And then I'm going to choose the check box that says Automatically replace instance_name_here when applying code snippet. So I'll check that box and then click OK. In the Code Snippets panel, you'll see there's a new folder called Custom, and if you expand it, you'll see Advanced Keyboard Control. To apply it, I'm first going to delete the Actions layer, and then I'll double-click Advanced Keyboard Control. Since I didn't have the object selected on the stage, I'm informed that this action requires an object to be selected.

So I'll select the instance on the stage. Note that its instance name is biker, and then I'm going to double-click Advanced Keyboard Control. Code is then added to the Actions panel, and if I scroll all the way to the bottom, the instance name is inserted in there instead of instance_name_here. So my code is ready to go. All I had to do is select an object on the stage and then double-click. So I'll test the movie, and using my keyboard, I'll move the biker on the stage. So when you're working with the Code Snippets panel, you can add new snippets by writing the code out, selecting it, and then choosing Create New Code Snippet from the Options area of the Code Snippets panel.

All of this data is actually saved in an XML file, which you can edit if you choose Edit Code Snippets XML. If you ever want to reset to default, you can choose Reset to Default XML to delete your custom snippets. You can also import, as well as export, code snippets. So with the Code Snippets panel, you can create customized code snippets, and you can easily reapply them to objects on the stage.

There are currently no FAQs about Flash Professional CS5 New Features.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flash Professional CS5 New Features.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked