Third, depth (depth)
Depth (depth) only requires a numeric description, Flash Player uses this number to specify the laminated position of the object. The stack refers to a cover relationship when a display is displayed. The depth value is large, and the depth value is smaller, the depth value is smaller, and the next time it is to be covered. The depth has comparable but limited to the brothers, so the brothers under the same parent have different depths, and this depth also describes the laminated relationship between them. The child node belonging to different parent nodes can have the same depth, but they do not have comparable.
In the editing environment, Flash uses a layer to organize an object. At this time, Flash does not specify a depth to the object, only when the Flash document is running, Flash Player is specified according to the user's drag and drop in the editing environment, specify the depth of the object. The layer here can be considered as a collection of submitting axis nodes under the same parent time axis node. There is no intersection between the layer and the layer, and the layer is a dynamic set, and the elements in the collection will also change as the program is running. Flash can also create a time axis during runtime, such as using attachmovie (), duplicatemovieClip (), but must give the depth of the time axis to be created in the form of parameters.
The object is used to help Flash determine the depth of the object to help Flash in the sequence of drag and drop in the editing environment. Layers are not referenced in ActionScript, so there will be no layers in the SWF file. At compile time, the layer is decomposed into multiple objects (multiple time axes), and each object is specified for a depth. When Flash is played, the time axis reads the contents in the layer and specifies its depth according to the relative positional relationship between the other objects. If the layer where the object is located, a relatively high depth is obtained, and if the layer where the object is located, a lower depth is obtained. At the same time, Flash will also specify a name for the object to implement the script to the object. The depth concept also affects the creation of objects in Flash. You can set the order in which objects created in FileàPublish Setting àLoad ORDER. Specifies whether to create a low depth to high depth (Bottom Up) or high depth to low depth (Top Down) Create, the default in flash is the former.
ActionScript also provides some depth-related methods and management objects:
Depth Method or Depth Management Obility Description Return Value MovieClip.attachMovie () Create a movie clip instance from the library. Created movie clips for movie movie movie () Create an empty movie clipped creative movie clip creative movie editing MovieClip.createTextField () Create a text box No return Value MovieClip.duplicateMovieClip () Create a copy of a movie clip Create the movie clip references MovieClip.getDepth () returns the movie clip depths depth value MovieClip.getInstanceAtDepth () returns the specified depth occupied by a movie clip at the specified depth of a movie clip references MovieClip.getNextHighestDepth () returns the highest available depth depth value MovieClip. RemoveMovieClip () Remove Dynamic Create Movie Clip Non-return Value MOVIECLIP.SWAPDEPTHS () Exchange Two Movie Clips Depth Non-return Value DEPTHMANAGER Component Depth Manager
Depth method and function description
It is desirable here that the swapDepth () method can separate two objects of different depths. If there is two ways to implement this case: First, the two objects are swapped, that is, take the above, take the following, which is the object itself; the second is to directly change the depth of the object Attribute, ie the value of the specified object depth is directly modified. However, if the latter is obviously not the depth of exchange but is set. The swapDepth () method is to implement the exchange of object depth points rather than setting depth. You can understand the depth as a container, such as a house, if two people want to exchange the house, then you must be moving over, but only replacing the house is nothing. So the depth is read-only. In addition, the getDepth () method can easily obtain depth data of MovieClip, Button, and TextField objects. In addition, depth manager is a Flash V2 component that is managed deeper, which encapsulates several depth management methods:
DEPTHMANAGER.CREATECHILDATDEPTH (): Create a child level of the specified component at the specified depth.
DEPTHMANAGER.CREATECLASSCHILDATDEPTH (): Create an object of the specified class at this specified depth.
DepthManager.createClassObjectDepth (): Create an instance of the specified class at the specified depth.
DEPTHMANAGER.CREATEOBJECTDEPTH (): Create an object at the specified depth.
DEPTHMANAGER.SETDEPTHABOVE (): Move instances above the depth of the specified instance.
DEPTHMANAGER.SETDEPTHBELOW (): Movement instance to the depth of the specified instance.
DEPTHMANAGER.SETDEPTHTHTO (): Move the instance to the depth.
Fourth, depth area:
The three areas on the depth must be clearly understood when the depth is specified for the object. In Flash, the depth range is between -16384 to 2130690045, and any Flash visual object will not exceed this range. When playback, Flash loads objects in the timeline in accordance with the default settings. -16384 to -1 is the first range of depth, which cannot be created and removed using scripts in this depth area object, which is used to place the user created in the editing environment. Here it is called the Timeline. . Next, the depth range of 0 to 1048575, within this depth, the object can be created and removed using scripts, so it is called dynamic. The subsequently referred to a reserved area (RESER), the depth range is between 1048576 and 2130690045, but MC can be placed but cannot be removed.
Depth area of Flash:
Regional Depth Range Feature Time Shaft Area -16384 to -1 is mainly used to place objects of flash editing, and objects cannot be removed by script, but can be created using scripts. Dynamic Zone 0 to 1048575 Realize the dynamic creation, dynamic access, and dynamic removal of the runtime 1048576 to 2130690045 Realize the dynamic creation, dynamic access, but does not support the use of script removal objects.
Flash provides a time axis in the dynamic zone to place objects in the time axes in the editing environment. In the editing environment, the bottom object is placed in the deepest place in the area --- 16384. At the beginning of the usual case, the depth of -16383 is usually, Flash places objects in the time axis in a higher depth.
Next is a dynamic zone, where you can place objects that can be dynamically created and removed. And this area is also in line with the usual use habits because its depth begins from 0, and developers will usually consider this range when creating objects. In this range, you can get a relatively large free weight, developers can dynamically create and remove objects using scripts. If the object is not in the dynamic area, you first swap objects to the dynamic zone and then remove it. The reserved area can be understood as an extension of the dynamic zone, but the object cannot be used in that area in that area, which can be dynamically created in that area in the reserved area. In this area object, you can also exchange to other depth areas using a swapdepth () method. But the reserved area is still a particular area because the objects there can not be removed, and the depth is a bit odd. The reserved area Flash provides a certain storage space.
It is important to note that it is almost no restriction on the depth allocation in the depth assignment in the depth assignment, and the depth can be specified below -999999999999999999999999. Although this depth has exceeded the range just discussed.
V. Timed shaft refresh:
About depth, there may be some problems that are confused, especially dynamic zones and time axes. When the time axis is refreshed, all objects will be recreated. Flash scans the time axis area located at this timeline and clears the object stored on these depths. Then Flash read the data on the timeline and recreate these objects, but the object created by the dynamic approach will be ignored. One of the examples is to use gotoandplay () to return to play the played frame, such as returning from the 10th frame to the bottom 5 frame, then Flash must refresh the time axis in order to re-exhibit the content of the 5th frame and fully refine the 5th frame. content. However, the object created using a dynamic method If it is removed when the time axis is refreshed, then it is not automatically created, unless the program gives it.
Obviously, this may cause some problems. First, this will lose the object that has been created and exchanged to the timeline area in the time axis region or using a dynamic method. That is, in this case, it is not possible to exchange objects created using dynamic methods to the timeline area, otherwise these objects are lost when the timeline is refreshed. In developing, in order to avoid this, you can create a single frame stopped MC, such a MC can be safe, and it is not necessary to worry about the time axis.
Another problem is that the object that needs to be removed cannot be removed. The reason is due to the use of the depth switching method to transfer the object of the time axis to the non-timeline area, which cannot clear the object when the time axis is refreshed, and this refresh also creates a new object to the time axis . This situation should also be avoided.
There is also a question that needs to be clear is the problem of Scene jump. The jump in the scene does not cause the time axis to refresh, nor does it trigger other special events. As the scene itself, they are fragments of the primary timeline. After the Flash is released, these scenarios will be integrated together to become a single main timeline. So the user created by the user, which can still appear in the next scene, of course, can also use scripts to make those objects disappear.
6. Player execution order:
On the depth issue, it is easier to be ignored by people. As mentioned earlier, the depth also affects the execution order of the script. In fact, the depth itself does not affect the order in which the script is executed, but the depth is related to the order of the object. Generally, we will consider that on the same time axes, the object that is first created will first execute the script it contains. Another person is strange that under the default publish settings, those that are created, but first execute the scripts in the Enterframe event. By default, objects are created from the bottom of the bottom, which we can set in the Flash release option. The frame script is performed in the order they are created. Thus, if in the bottom UP mode, from the technical point of view, the lower layer script is performed earlier, but it is worth mentioning that the script in the EnterFrame event has just been opposite. It seems necessary to investigate what an ENTERFRAME event is an event. ENTERFRAME events are continuously triggered with the frame speed of movie clips. It can be considered that an Enterframe event is an event that triggered when the play head enters a frame, but the code in the Enterframe event will be executed with the frame script. However, what is the relationship between the creation of an object and the playback of Flash (the change process of the object state)? The frame script of the frame script and other frames in Flash have different behaviors. When running a SWF file, its first frame will be created first, then start loading the object in the document and dragging into the stage, which can be considered an initialization process. So in this process, the capacity of the first frame of the object will continue to increase. The reason for this is also obvious. Only when the object is all loaded, the script can be executed, and the script will inevitably errors if the objects to be operated by the script do not exist. Once all objects are loaded, other frames other than the first inframe will be created one-time and played. Another reason for this is that if you create, first play the principle of playing first, then it will inevitably lead to inconsistencies when movie clips play. Because creating objects are time, especially on the network, it has a download process. It is also important to note that #initclip and code blocks in #ENDINITCLIP, which are usually defined in the first frame of movie clips, as long as the symbol is defined and compiled (the movie clip symbol is defined, but not necessarily compiled), then This code segment is executed, which is used for the initialization of the movie clip, so it takes precedence over other scripts, and only once, its running effect will act to all instances of the clip.
In this way, it can be concluded that the execution of Flash can be divided into two processes. The first is the object's download, creation, and initialization, next to a playback process. Playback is an object state as a process of frame speed changes, and the two extremes of its state exist and absence. In this way, the script of the movie clip first frame will be executed during the execution of the flash; then the process of playing the script is the execution of the Enterfrane event script.
Seven, Layer, Level (Level) and Depth (DEPTH)
Usually people will confuse the layer and hierarchy, but in fact they are two completely different concepts. The timeline can be independent of the main timeline in two ways: Movie Clip and Level. Here, so-called independence refers to independent playback and stop. Layer, which is only seen in the editing environment, the object used to store and organize on the timeline. They are only just in the editing environment. When a Flash file is released, these layers will be compressed to the same time axis.
Level (Level) is located on a separate timeline for storing external SWF files loaded using the LoadMovie method. Level (Level) can use _LEVEL0, _LEVEL1, _LEVEL3, _LEVELN to reference it. The higher the level, the closer to the observer, the easier it is, and this is consistent with the depth. The movie loaded using this method will penetrate the main timeline of the movie. Since this reason is to load movies from the outside, it is often to load some sounds because the sound does not affect the playback of the original movie. Movie clips are also a separate timeline, but the movie clip is located in the library, not outside the movie. So it is different from the hierarchy, if needed, you can create a movie clip on the frame. Drag a movie clip to the stage from the library, then an instance of the movie clip can be created, you can specify a unique name to reference it. Movie clips can contain other movie clips, which is usually nesting.
Depth (depth) is usually used for swapDepth () and attachmovie () methods for specifying the laminated order of the movie clip. It can be considered a visual object in the laminated order (Z-Order) on the timeline.
It is also pointed out here.
_root
with
_level0
Differences.
_root
with
_level0
The reference is not the same object, which is different.
_root
Refers to the main timeline of the movie, if a movie has multiple levels?
_root
Refers to the hierarchy that the current script is executing. For example: at level
n
A script in the middle contains
_root
At this time
_root
return
_leveln
,
_root
with
_leveln
It is equivalent.