-
why does everyone _root. everything?
doesnt:
stop();
work just as well as:
_root.stop();
or does the _root. make it faster?
-
Senior Member
It depends where the code is run, if you are in a method of a class, stop() controls the instance that is calling the method, _root would be needed to control the main timeline. You'll notice though that a lot of people don't like using _root, because _root can change if you import the game .swf into a container .swf, the _root becomes the containers .swf.
There is a way around it, which I hadn't heard about until awhile ago which is _lockroot.
For anyone interested here is a link to an article about it. It is pretty nifty.
http://www.flashinsider.com/2005/08/...-_rooted-code/
Hope that clears things up.
Edit: Another way of thinking about it is stop() is the same as writing this.stop(), so if you are in the main timeline this=_root, so _root.stop()=stop(). When this changes from being called by a method or inside a clip, then you have to use _root, or a path to root like _r to access it.
-
thx for the info and i get it too
-
Phantom Flasher...
Yup, I try to avoid _root. _parent. works just as well, may be a little slower though
-
Hype over content...
Slightly off on a tangent but one thing which a lot of people miss and can lead to pulling your hair out errors is gotoAndStop/Play.
If your using that on a mc ( ie, within your enterFrame / load code ) always put this. infront of it ( If you want to alter the frame of the mc itself that is ).
It stops the local / global method conflict.
Squize.
-
Senior Member
Huh?
I just figured anything with _root. befor it affects to stuff on the main timeline and without it it affect the MC wich the code is in??
EG : _root.gotoAndPlay(2); play frame 2 in your main timline and
gotoAndPlay(4); playes frame 4 in your MC
Am i mistaken?
92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!
-
Hype over content...
Not really, but Flash being the little minx that it is can get mixed up sometimes, so just get in the habit of adding this. when doing it on a mc.
Squize.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|