How to understand correctly

Source: Internet
Author: User
_root/_level/depth is the basis in as, the correct understanding of the three roles and relationships, as the primary learners have a great help ...

Recently saw a lot of friends posted said not clear _root and _level is doing, there is a depth (depth). Often make people dizzy. XX (so the pain of determination must let you understand.) If you think that the right to give a little applause, think that the wrong to throw a bit of bricks in passing together to study.

_level and Path

  Before you start the tutorial, talk about the directory structure of the file, because this structure is very similar to the path structure in the SWF

There is a mypath.swf file on my computer, which is stored in the downloads directory of a star algorithm in my computer's C disk. When we visit, we can visit C:\downloads\A star algorithm instance \mypath.swf. This long string of paths illustrates where mypath.swf is stored in my computer. The same rules are followed in Flash for the storage of MC or other objects in SWF.

Or take the above example, if we think of my computer as a flash file, then the following C D e disk is equivalent to the _level0 _level1 _level2,downloads and a star algorithm in flash the two directories are equivalent to two MC, And Mypath.swf is the final MC. and file access the same way here to visit mypath.swf you can use the _LEVEL.DOWNLOADS.A star algorithm instance. (mypath.swf) asked him for a visit. Is it a little clear? But note the above _LEVEL.DOWNLOADS.A Star algorithm example. (mypath.swf) Just explain that when the principle is actually used you can't name the MC with mypath.swf.

about _root

_root is equivalent to the root, or first use the first picture of the file structure to illustrate: for the C:\downloads\A star algorithm instance \mypath.swf this file, its root is the C disk. For any of the files in the C disk, her root is the C disk, and for any one of the D-disk files her root is D-disk and so on. The same is true in Flash. For any _LEVE0 MC, its _root is _level0. And so on.

What is depth

Depth represents depth, which is not the same as _level and _root. Because depth as far as the display is concerned, the larger the depth, the more it appears on the top. The most important role of _level and _root is to identify the path of the MC in Flash.

Note that _level have their own default depth, and each MC has its own depth to allocate.

Why say _level have their own default depth. Because all the _level (including _level0, _level1, _level2 ...) They are actually subordinate to a higher level of MC, presumably the SWF itself. _level0 is located in SwF 16384 this position _level1 is located in SwF 16383 this position, and so on, Flash probably supports 955,599,999,999 _level (the specific does not have the book), if still use the way of document to understand, So that means you can have around 955599999999 of the letter.

If you don't want to use the system to _level the default depth you can even Exchange _level0 and level1 depth, don't believe it. Try to find out.

Let's do an example to illustrate

A new file is opened in Flash, the first frame is written to Loadmovie ("logo.jpg", 1); The logo.jpg of course here is to fill in any of your local JPG files and then create a new layer to draw something in the first place, to ensure that this layer has been existing to 30 frames, we must ensure that the new loading of the picture and the above layer of things overlap, or can not see the effect.

Frame 15th Write

Trace ("_level0 depth=" +this.getdepth ()); Trace ("_level1 depth=" +_level1.getdepth ()); This.swapdepths (1);

Frame 30th Write

Trace ("_level0 depth=" +this.getdepth ()); Trace ("_level1 depth=" +_level1.getdepth ());   Stop (); Okay, so run the following, and you can see that when _level0 and depth 1 are switched, the _level0 on the top of the _LEVEL1 results

_level0 depth=-16384
_level1 depth=-16383
_level0 depth=1
_level1 depth=-16383

Isn't it fun?

Tip : There must be something in each level to trace, and if you don't use Loadmovie to _level1, then Trace (_level1.getdepth ()) is invalid.

Each MC mentioned earlier has its own depth to allocate, which is understandable. That is, if _level1 can have their own depth 1 position Mc,_level2 can have their own depth 1 position of the MC. Two will not conflict, who shows up at the front depending on _level2 and _level1 who's depth large depth (depth).

Add : The so-called depth (depth), which is the superposition of several MC positions. The greater the depth (depth), the higher the position. If you have the experience of AW, then this is similar to its layer, which can cover the bottom.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.