Home > Articles > Web Development > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

Methods

A method is something an object can do or something you can do to an object. For example, here are some things methods can do:

  • Stop a movie clip.

  • Go to a certain frame and start playing there.

  • See if a movie clip is over another movie clip.

  • Hide the mouse cursor.

  • Calculate a cosine.

  • Set the volume of a sound being played.

Let's go to frame 10 of the clue movie clip and start playing from there:

clue.gotoAndPlay(10);

The method here is gotoAndPlay. All methods live inside objects—they don't exist on their own.

NOTE

Even when you see methods that look like they don't belong to an object—for example, a frame action whose only line of code is stop()—it's understood by Flash that the object in question is the movie clip the frame is in: It will always assume this.stop(). If the frame is in the main timeline, then the default timeline is _root, resulting in _root.stop().

Remember we said that all movie clips you make are objects based on the master MovieClip class? Well, that class has a whole bunch of properties and methods associated with it, and when you make a MovieClip object, all those properties and methods become a part of your movie clip. This is a good thing—those properties and methods are vital to creating interactive Flash, and it would be a pain to have to create all those properties and methods yourself.

  • + Share This
  • 🔖 Save To Your Account