Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 

 
_root, _parent, and this
         by ilyas usal

  1. _root
    _root is an alias, just as _parent and this. It is used to access the root of the current level. For instance, if you write this in the first frame of your movie:


 

Quite normal, since the default level is 0. But if you load a movie in _level1, and if that movie is referring to _root, it will mean _level1. So be careful about that: to access the _root of the master movie from the loaded movie, you have to write:

_level0._root.myVariable = ...

  1. _parent
    OK, now _parent is quite similar, except it refers to the clip that is one "layer" higher in the tree. In this example, _root creates (hence contains) firstClip, so it is his parent, firstClip creates secondClip, which creates thirdClip:
     


 

  1. this
    this refers to the current object. It is particularly useful in Flash MX when you build a prototype, as we will see later.
    It is also vital now that Flash handles variables scope differently. In Flash 5, declaring a variable in an onClipEvent(enterFrame) made the variable relative to the clip. It's over now, since all the variables left alone are relative to the current timeline. That's why if several objects use the same method, prototype or function at the same time, they can all modify the same variables, so the animation cannot run normaly.
    That's why you have to tell Flash when your variables depend on the current object by declaring them as part of this:

    onClipEvent (enterFrame)
    {
         this.myVar = 5;
    }

    If you hadn't put this, and that there was a variable called myVar on the _root, this variable would have been replaced by that one. You see the problem?

Hope this tutorial helped. If you have any questions, please post them on the forums at http://www.kirupa.com/forum/

 

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
flash components Free Website | Make a Website
Streamsolutions Content Delivery Networks Learn how to advertise on kirupa.com