|
|
||||||||||||
|
|
Ultrashock Tutorials > Flash5 > Targets in Flash5 | |||||||||||
|
||||||||||||
|
|
Targets in Flash5 |
|
||||||||||
|
Where are you? Movie clips are the basic building blocks of advanced Flash work. Movie clips are unique because thay have their own timeline and are not linked to the playback of other timelines. By nesting movie clips within one another we can produce some amazing effects. We can use actionscript to control anything about a movie clip from its position to the frame it displays. Targets are used to identify a timeline within Flash using their instance names. A simple example
This is an example of nested movie clips. The rotation tween lies in one movie clip which is inside of a fade tween movie clip. The little stop and go buttons allow the user to control each of these separately. Remember that the targets refer to instance names and not to the names of symbols in the library. To see the actions download the source file. Absolute vs. relative Targets come in two flavours: relative and absolute. Absolute paths identify the timeline relative to the parent, or main timeline. They begin with '_root' and work their way down to a particular instance (e.g. _root.instance1.instance2). Relative targets identify the timeline based on where it is in relation to the current timeline (e.g. "instance1.instance2"). There is a special case for relative paths that can be very useful. The target '_parent' refers to the timeline one level up. So if you were to refer to '_parent' within instance2 you would be targetting instance1. If you were to use the same target inside instance1 you would be targetting the parent timeline. It is often preferrable to use relative paths because they are less dependant on the overall structure of your project. Because of this, it is easier to move actionscript that uses relative paths from one spot to another. Old School vs. New School Until Flash5 targets used a slash syntax which was modelled after the file structure system (e.g. "/instance1/instance2"). While Flash5 can still handle this format, it introduced a much more elegant format referred to as "dot syntax". Here are a couple of comparisons if you are already familiar with the older style.
Forget TellTarget It was fun while it lasted but the new dot syntax of Flash5 makes TellTarget redundant. While you can still use the TellTarget action, as well as the old slash targets, you will be better off learning how to master the new dot syntax and the use of the 'with' action. The dot syntax provides a much more powerful way to associate actions with other timelines. The first is to tack on the action after the target:
label_name = "start";
If you have several actions that you want performed on a particular instance then use the with action:
label_name = "start";
In some ways the with statement is similar to the old TellTarget. TellTarget was different in that it was as if your code was transported into the new target and you had to watch out for references to variables. For example, the following code would fail to work because the variable "label_name" is set in a different timeline than the 'Go to and Stop' action.
Set Variable: "label_name" = "start"
|
||||||||||||
|
|
©2001 Ultrashock.com Inc. - All rights reserved
|
|