WHats the diffrence?

Hi all im just curious to know whats the diffrences and what is best to work with: Dots, Slashes, Relative and Absolute im sure once i know this it will clear up some headaches for myself and for other fellow flashers that dont know what are these used for thanks

Grim

Dot syntax is the only method you should use now.

The slash syntax went out with Flash 4 I believe.

As for relative and absolute, I am assuming you are talking about positioning. You can only do relative positioning on the stage in MX, but really, it is up to you and what you are doing on which one of those you want to use.

relative and absolute as in referencing
ex:

_root.box.kitten

if in kitten:

//absolute reference of box clip
_root.box
//relative reference of box clip
_parent

absolute is from the root object in the hierarchy while absolute is from the object your in.

robert penner never uses the term _root (so he says) and I assume always references relatively, though if accessing a clip in _root which is 4 or 5 levels up, I doubt you’ll have a problem using _root instead of _parent._parent._parent._parent._parent (etc). The only problem _root can give is when loading in external swfs into movieclips. Then _root wont reference the same scope it did when that swf is played on its own. _root then references the main movies _root where what _root DID reference is now the clip you loaded the movie into.

Ive seen some people use _level0 instead of _root. This can be fine for storing variables (since _level0 is level 0 no matter what level you are in) but, again, as with before, if you reference movieclips using _level0 absolutely and your swf is loaded into another movieclip/level your references will get thrown off. Besides, for variables now, theres _global, so you really wouldnt want to use _level0 for that either.

Then theres also the fact that _parent isnt read only. You can make _parent to be anything you want, and if you change the _parent variable in any movieclip (even if accidentally), you wont be able to do much in terms of relative referencing going up levels. With that in mind, lets not change or alter _parent’s value. :wink:

I personally take the shortest route to a movieclip scope - whatever takes the least to write, though often I dont use _root unless I KNOW that the clip being referenced is always in _root. For a generic “click me to move this clip up 5 places” button, for example, I wouldnt use absolute referencing because I might want to use that button again in some other scope, and if I can get away with not having to alter the code on that button again, I will (i.e. just use on(press) {this._parent._x+=5} or whatever).

A good practice is to use variables to reference clips and not thier actual clip name. Then, should a design change cause the scope of your referenced clip to unexpectedly change, all you would have to do is change that one variable and not all the instances you used a direct reference to that movieclip itself.
ex:

mc = _root.box.kitten
mc._x = 10;
mc._alpha = 50;
mc.Show_x = function(){ trace(this._x); };

(some change takes the kitten out of the box and puts it in the dryer)

mc = _root.dryer.kitten; // <-- only change needed
mc._x = 10;
mc._alpha = 50;
mc.Show_x = function(){ trace(this._x); };

Oh… LOL. OMG, the thought of referencing never even crossed my mind that is why I was all confused like.

'DOH! :hangover:

:blush: :beam: