• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 5. Controlling Multiple Timelines > Absolute and Relative Paths

Absolute and Relative Paths

Flash gives you two mode options in the Insert Target Path dialog box: relative and absolute. In the preceding example, the method this.train_mc.wheels_mc.stop() originated from the main Timeline. When Flash executes that method, it looks within its own Timeline for the object called train_mc that contains another object called wheels_mc. This is an example of a path that uses relative mode. Everything is relative to where the ActionScript statement resides—in this case, the main Timeline. An alternative way of inserting a target path is to use absolute mode, which has no particular frame of reference. You can think of relative target paths as being directions given from your present location, as in “Go two blocks straight; then turn left.” Absolute target paths, on the other hand, are directions that work no matter where you are, as in “Go to 555 University Avenue.”

Why Relative Paths?

Why use relative paths at all? Absolute paths seem to be a safer construction because they identify an object explicitly no matter where you are.

Relative paths, however, are useful in at least two cases:

  • If you create a movie clip that contains actions that affect other movie clips relative to itself, you can move the entire ensemble and still have the target paths work by using relative terms. This method makes it easier to work with complex navigation schemes because you can copy, paste, and move the pieces without having to rewrite the target paths.

    A direct parallel is managing a Web site and maintaining its links. If you were to create absolute paths to links to your résumé and then move your home page to a different server, you’d have to rewrite your links. The more practical method would be to establish relative links within your home page.

  • Relative paths are also useful when you create movie clips dynamically. You will learn how to create movie-clip objects and name them on the fly with ActionScript. In these cases, movie clips are not static and relative target paths are required to follow them around.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint