Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Flash Professional CS5: Code Snippets and Templates in Depth

From: Flash Professional CS5: Code Snippets and Templates in Depth

Video: Showing and hiding movie clip instances

It's very common in a Flash movie to create objects on the Stage that you want to have hidden when the movie first appears to the user. You handle this by setting a property called Visible to a value of False and you do this in ActionScript code. You can use a code snippet to create this code very simply and easily. I'll start this demonstration with a file from the Exercise Files area, in the Ch01_SimpleSnippets folder named OliveGameWithLabels.fla. In the beginning state of this movie I have six layers in the timeline.

Showing and hiding movie clip instances

It's very common in a Flash movie to create objects on the Stage that you want to have hidden when the movie first appears to the user. You handle this by setting a property called Visible to a value of False and you do this in ActionScript code. You can use a code snippet to create this code very simply and easily. I'll start this demonstration with a file from the Exercise Files area, in the Ch01_SimpleSnippets folder named OliveGameWithLabels.fla. In the beginning state of this movie I have six layers in the timeline.

The three layers named rosemaryLabel, orangeLabel, and jalapenoLabel, each of these contains a single label object. And in the bottles layer, there are three movie clip instances showing images of bottles. The labels are designed to be displayed one at a time. As the movie first appears in Flash Player, I don't want them to be shown. So I need to set the Visible property to False. There's a very simple way of doing that, again, using a code snippet.

I'll start in the first layer named rosemaryLabel. I'll right click and choose Lock Others and then this will allow me to choose the one and only object in the layer. After I've selected the object I can then apply a code snippet to it. I'll go the menu and choose Window > Code Snippets and then I'll go to the Actions category. There are two possible code snippets you can use here. One is named Click to Hide an Object and the other is named Show an Object. I want to hide the object but I don't want to respond to a mouse click.

So I am going to start off with the Show an Object code snippet and I'll double click it, which will add an Actions layer and add the bit of code I need. Here is the code that's been added, rosemaryLabel_mc.visible=true. Now what I really want to do is hide the object when the movie first appears, so I'll change the value of true to false. And then I'll delete the comments that are added at the top of the code snippet. I don't really need them. Now I am going to repeat the process for the other two label objects.

I'll close the Actions panel. Next I'll go to the orangeLabel layer, right-click, and select Lock Others. Then I'll click in the layer to select the one and only object in that layer and once again I'll double click on Show an Object. I'll change the value of the Visible property from true to false and, once again, I'll delete the comments. I'll move the cursor down to the bottom of the existing code and I'll repeat this one more time, this time for jalapenoLabel. I'll right on the layer, choose Lock Others, click to select the object, double click on the code snippet, change the value from true to false, delete the comments, and now as the movie shows up in Flash Player, these three objects should be invisible.

I'll close the Actions panel and then test the movie. Now the labels don't appear in the movie. Now in another video, I'll show you how to use those labels and show you how to make them appear and disappear as the mouse floats over each of the three bottle images. Once again, I'll use code snippets to build the code and do a little bit of customization along the way.

Show transcript

This video is part of

Expand all | Collapse all
  1. 4m 40s
    1. Welcome
      1m 32s
    2. Understanding the prerequisites
      1m 42s
    3. Using the exercise files
      1m 26s
  2. 39m 39s
    1. Using code snippets
      4m 7s
    2. Touring the Code Snippets panel
      2m 51s
    3. Adding a simple code snippet
      3m 28s
    4. Adding a complex code snippet
      7m 45s
    5. Applying code snippets to movie clip instances
      5m 25s
    6. Showing and hiding movie clip instances
      3m 20s
    7. Handling common mouse events
      8m 1s
    8. Handling keyboard events
      4m 42s
  3. 36m 21s
    1. Adding Play and Stop actions
      5m 27s
    2. Handling the enterFrame event
      8m 5s
    3. Managing multi-scene presentations
      8m 14s
    4. Adding drag and drop
      6m 33s
    5. Rotating objects
      5m 5s
    6. Fading objects
      2m 57s
  4. 27m 14s
    1. Starting and stopping sounds
      7m 24s
    2. Showing video with FLV Player and ActionScript
      5m 15s
    3. Showing video with NetStream
      4m 19s
    4. Stopping, pausing, and resuming video
      5m 19s
    5. Seeking a cue point
      4m 57s
  5. 22m 49s
    1. Loading external SWF files
      4m 50s
    2. Adding library symbol instances to the Stage
      6m 40s
    3. Loading external images
      7m 26s
    4. Loading external text
      3m 53s
  6. 14m 36s
    1. Exploring the Code Snippets XML file
      4m 12s
    2. Modifying an existing code snippet
      3m 0s
    3. Adding a custom code snippet
      3m 41s
    4. Managing code snippet categories
      3m 43s
  7. 36m 5s
    1. Understanding template types and categories
      4m 33s
    2. Creating clickable advertising presentations
      6m 10s
    3. Reusing movie clip symbols from templates
      6m 10s
    4. Replacing content in a new file template
      6m 56s
    5. Randomizing movement in movie clip symbols
      6m 1s
    6. Scripting movement in animations
      6m 15s
  8. 18m 50s
    1. Creating a photo album
      4m 38s
    2. Creating a simple slideshow presentation
      4m 13s
    3. Creating an advanced slideshow presentation
      5m 35s
    4. Creating a desktop slideshow with Adobe AIR
      4m 24s
  9. 18m 45s
    1. Counting down dates
      3m 38s
    2. Panning a landscape
      5m 51s
    3. Revealing text with masks
      3m 48s
    4. Animating with inverse kinematics and bones
      5m 28s
  10. 42s
    1. Goodbye
      42s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

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.


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.

Join now Already a member? Log in

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: Code Snippets and Templates in Depth.

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 preferences from the dropdown menu.

Continue to classic layout Stay on new layout
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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.