Flash 4 into Flash 5: Targets and Paths Explained Flash

However, you might not have guessed that Movie Clips can also add logic to animation and Flash interfaces. Let’s take our animated face example a little further: When people yawn, they generally close their eyes for as long as they are yawning. Our hypothetical character’s face may look strange if it is blinking and yawning at the same time. Suppose we wanted to make our character’s eyes stay closed during every yawn. We’d have to have some way for the mouth Movie Clip to control the eyes Movie Clip so that we could tell the eyes to go to a “shut” frame when the mouth opens, and then tell them to return to their blink loop again when the mouth closes.

Well, we have a few ways to control the eyes Movie Clip from the mouth Movie Clip. In Flash 3 and 4, the Tell Target action was used to let actions on any timeline (including Movie Clip timelines and the Main Timeline) control what happens on any other timeline. How? Tell Target simply provided a mechanism for extending actions, enabling them to specify (or target) the timeline upon which they should be executed. Targets are any Movie Clip instances that are available at any given frame in a Flash movie. In addition to Tell Target, Flash 5 enables you to direct actions to specific timelines by attaching the same actions as methods to the Movie Clip object. If you’re new to scripting, please read the “The New and Improved ActionScript” sidebar.

The Tell Target action is a deprecated action; it’s still supported in Flash 5, but it’s been replaced with more versatile actions and syntax that make its use outdated.

Paths: Absolute and relative modes
Earlier, you learned how multiple Movie Clip timelines appear on the Flash Stage. It’s entirely possible to nest several Movie Clips within another Movie Clip. To understand how Movie Clips communicate with one other by using actions, you need to have a firm grasp on Movie Clip paths. A path is simply that the route to a destination, an address per se. If you have a Movie Clip instance named dogTailAnim inside a dog Movie Clip instance, how is Flash supposed to know?

What if there was one than one dogTailAnim in the entire movie, with others nested in other Movie Clips besides the dog instance? You can specify a Movie Clip’s path in an absolute or a relative mode.

An absolute path is the full location (or target) information for a given Movie Clip instance from any other location (or target). Just like your postal address has a street name and number and a zip code so that people can find you on a map, all
Movie Clips have a point of origin: the Main Timeline (Scene 1). Before Flash 5, the Main Timeline was represented in a Movie Clip path as a starting forward slash (/) character. The absolute path of a Movie Clip instance named dog on the Main Timeline is:

/dog

Any nested Movie Clips inside of the dog instance would be referenced after that starting path. For example, the absolute path to dogTailAnim, an instance inside the dog Movie Clip instance would be:

/dog/dogTailAnim

Another / character was put between the two instance names. Think of the / as meaning “from the timeline of,” as in dogTailAnim is from the timeline of dog. Use of the / character in Movie Clip paths is known as the Slashes notation. In Flash 5, you can use either the Slashes or Dots notation with absolute paths. The Dots notation follows the new ActionScript language conventions. With Dots notation, the Main Timeline becomes:

_root

Using our previous example, a Movie Clip instance named dog on the Main Timeline (or _root) would have an absolute path of:

_root.dog

And, following in suit, a Movie Clip instance named dogTailAnim that is nested within the “dog” Movie Clip would have the absolute path of:

_root.dog.dogTailAnim

Just like Tell Target is considered a deprecated action in Flash 5, the Slashes notation is deprecated syntax. It will still work with the Flash 5 Player, but subsequent versions of the Flash authoring program will be built of the new Dots notation.

A relative path is a contextual path to one timeline from another. From a conceptual point of view, think of a relative path as the relationship between the location of your pillow to the rest of your bed. Unless you have an odd sleeping habit, the pillow is located at the head of the bed. You may change the location of the bed within your room or the rooms of a house, but the relationship between the pillow and the bed remains the same.

With Flash, relative Movie Clip paths are useful within movie clips that contain several nested movie clips. That way, you can move the container (or parent) Movie Clip from one timeline to another, and expect the inner targeting of the nested movie clips to work. As with absolute paths, there are two methods of displaying relative paths: Slashes and Dots notations. To refer to a timeline that is above the current timeline in Slashes notation, use:

../

The two dots here work just like directory references for files on Web servers; use a pair of .. for each timeline in the hierarchy. You can use relative Slashes notation to refer up and down the hierarchy at the same time. For example, if you have two nested movie clips, such as dogTailAnim and dogPantingAnim, within a larger Movie Clip named dog, you may want to target dogTailAnim from dogPantingAnim. The relative Slashes path for this is:

../dogTailAnim

This path tells Flash to go up one timeline from dogPantingAnim to the dog timeline, and then look for the instance named dogTailAnim from there.

The relative Dots path for a timeline that is located above the current timeline is:

_parent

To target one nested Movie Clip from another nested movie clip in the same container Movie Clip instance, you would put the targeted Movie Clip’s name after

As with absolute paths, we recommend that you become familiar with using the Dots notation for relative paths. Okay, that’s enough theory. We’re going to let Colin Moock ease the transition of Flash 4 to Flash 5 targeting by showing how he uses Tell Target and Movie Clips with GWEN!, the star of his online animated series by the same name. Note that Colin’s material from the previous edition of the Flash Bible has been updated to reflect the Flash 5 look and feel of adding ActionScripts to Movie Clips. We have kept his original procedure intact. In addition to the intrinsic value of his methodology, we’re also using this tutorial as an example of one way to migrate Flash 4 content to Flash 5. As you’ll see later, though, ActionScript offers new ways to address targets in Flash 5.

Using Tell Target and Movie Clips with interfaces
GWEN! is an example of using Tell Target to create enhanced animation. However, the same technique can also be used to produce interfaces. Interface-based Tell Targets are often implemented on buttons. Just as you used Tell Targets with actions on keyframes in Colin’s tutorial, so can you also use Tell Targets with actions on buttons.

While working at ICE during the spring of 1999, Colin produced much of the interactive component of McClelland and Stewart’s The Canadian Encyclopedia 1999 CD-ROM in Flash. Most of the interactive pieces used Movie Clips and Tell Targets extensively. A simple but good example of using Tell Targets to enhance an interface comes from the Painting Retrospective in the encyclopedia as seen in Figure below.

Depicts the Painting Retrospective in action shows below. Painting thumbnails are shown on a carousel that the user moves by clicking the right and left arrows. Below the carousel is a status window that displays the painting title, date, and artist when the user rolls their mouse over a painting. The status window is a Movie Clip that has one frame for each of the painting descriptions. The painting thumbnails in the carousel are all buttons. When the user points to a painting, the button’s Roll Over event handler initiates a Tell Target action that makes the status window Movie Clip go to the frame that contains the appropriate painting description.

Even when the paintings are moved along the carousel, the status window stays put because it’s a separate Movie Clip, not a part of the thumbnail buttons.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Flash Topics