PDA

View Full Version : _root? _parent?



invisibleloop
October 26th, 2004, 10:47 AM
Please help! I have a movie and in that movie external movieclips are loaded into a container movieclip (i.e. kirupa tutorial) The buttons actionscript looks like this:

on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = "about";
container.loadMovie("about.swf");
} else if (_root.currMovie != "about") {
if (container._currentframe>=container.midframe) {
_root.currMovie = "about";
container.play();
}
}
}

Within that external movieclip, another external movie clip is loaded into a container movieclip. Get me so far? So I mean the movies are loading into one another. I just need to know how to change the _root part of the script to make the second moviclip work!! see below:

movie/
container movieclip(button loads external movieclip here)/
External movieclip/
external container movieclip(button loads another external movieclip here)

3pinter
October 26th, 2004, 01:24 PM
_parent for the first one
_parent._parent for the second one

lunatic
October 26th, 2004, 01:45 PM
Just remember:

_root tracks the path to your movie clip from the main timeline INWARDS (in towards to nested movie clips)

_parent tracks the path from your nested movie clip OUTWARDS (out toward the main timeline).

:hr:

invisibleloop
October 26th, 2004, 01:55 PM
Just remember:

_root tracks the path to your movie clip from the main timeline INWARDS (in towards to nested movie clips)

_parent tracks the path from your nested movie clip OUTWARDS (out toward the main timeline).

:hr:
Cool that makes it a lot more clearer, I will try again. Thanks!

Gupps
October 26th, 2004, 04:10 PM
yeap it does just let me check it out and see if a get it. hahaha

what about "This." how does that work

lunatic
October 26th, 2004, 04:34 PM
"this" refers to the timeline of the movieclip you are using "this" with. For example, let's say I have a movie clip called "parent" and within that another movie clip called "child". If I am inside "parent" and I use "this" then "this" refers to the timeline of "parent". If I am inside "child" and use "this" then "this" refers to the timeline of "child". Does that make sense?

So if I am inside "parent" I can refer to the properties of "child" by saying "this.child" as in "this.child._width" for example. If I was on the main timeline I would use "_root.parent.child._width". If I was inside "child" then I would use "this._width".

The best explanation I have seen so far for the use of "this" comes from an OOP (Object Oriented Programming) tutorial written by Senocular. Don't be scared by the OOP concepts - just read the page on the use of "this" and hopefully it'll be clear.

http://www.kirupa.com/developer/oop/AS1OOPObjectScope6.htm

:hr:

Gupps
October 26th, 2004, 05:24 PM
thanks for the heads up lunatic

lunatic
October 26th, 2004, 05:26 PM
welcome =)

Sammo
October 27th, 2004, 05:34 PM
Thanks :)

lunatic
October 27th, 2004, 06:01 PM
:thumb: