all groups > flash actionscript > march 2006 >
You're in the

flash actionscript

group:

_root.link = action script help!


Re: _root.link = action script help! David Stiller
3/15/2006 5:01:47 PM
flash actionscript:
hennryflash,

[quoted text, click to view]
// etc.

So far, so good.

[quoted text, click to view]

When you say "route," do you mean _root? If so, _root refers to the
main timeline -- always. Well, almost always. _root is an interesting
phenomenon. Generally speaking, _root refers to the main timeline of the
movie you're in. Sometimes, though, for various reasons, you may want to
load one published SWF into another with something like
MovieClip.loadMovie(). When that happens, _root refers to the main timeline
of the *container* (the outer) SWF -- the one that loads the other. There
is only one _root, in other words, not a _root in the loaded SWF and another
_root in the container SWF.

And even here, there's an exception. The MovieClip._lockroot property
allows you to bypass the explanation I just gave, so that, in fact,
references to _root in the loaded SWF *do* point to that loaded SWF's _root.

But I'm guessing here that you're simply dealing with one, single SWF.
In which case _root refers to the main timeline of the SWF you're working
on.

[quoted text, click to view]

Well, there is no MovieClip.link property, so your reference to
_root.link is actually a reference to a variable (a property) you've created
yourself (or the template creator created him-/herself).

[quoted text, click to view]

Can you rephrase that question? I understand what you're asking.

[quoted text, click to view]

If I can understand you, I'll try to help. :)


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

_root.link = action script help! hennryflash
3/15/2006 9:29:38 PM
hi gang, ive got a flash template im trying to edit for a friend, id say im
fairly good at flash ive made alot of sites with actions but having trouble
with this.

the problem i have got is the _root.link=

this is the action script:
on (release) {
if (_root.link <> 8) {
_root.gotoAndPlay("w2");
_root.link = 8;
_root.page = _root.link;

}
}


(there was more but that was just controling the button animation, ive just
posted this to keep it simple , for me atleast)


what im having trouble doing is working out where the route is?
i want to be able to creat another movie and link it

eg:

on (release) {
if (_root.link <> 9) {
_root.gotoAndPlay("w2");
_root.link = 9;
_root.page = _root.link;

}
}


how would i lable the movie to be '9' where would i do this, i have looked and
ive had no joy, some help would be good, if u need more info from me please do
ask


Re: _root.link = action script help! David Stiller
3/15/2006 9:33:41 PM
hennryflash,

[quoted text, click to view]

:)

[quoted text, click to view]

No worries.

[quoted text, click to view]

Okay, this tells the timeline in which the button sits to go to a frame
labeled "s1" and play. This should occur when someone rolls over the
button.

[quoted text, click to view]

This tells that same timeline to go to a frame labeled "s2" and play.
This should happen when someone rolls out of the button.

[quoted text, click to view]

This tells the button to do something when someone clicks on it, then
releases the mouse. What happens depends on whether or not the value of a
variable named link is equal to the number 8. The location of this variable
is on the main timeline (aka the _root); in other words, not inside this
button, and not inside the timeline in which this button sits -- unless that
timeline *is* the main timeline. No matter how deeply nested this button
is, the if() statement is looking for a variable (link) in the main
timeline.

[quoted text, click to view]

_root is just an address, like the one on your house or apartments. If
someone lives on 221B, Baker Street, then you might address him thus in
ActionScript ...

221BBakerStreet.SherlockHolmes

.... the first part of the path is his residence, and the second part is the
man himself. In your example, you're looking for a variable, link, and that
variable lives in the main timeline. Since _root is synonymous with "the
main timeline," you may address this variable thus ...

_root.link

That's really all there is to it.

There's more than one way to refer to a variable, and it all depends on
where the variable is. If the link variable existed in the timeline of a
movie clip named clipA, and if clipA existed in the _root, then you could
reference link like this ...

_root.clipA.link

.... and that reference would make sense *from the point of view* of the
_root. If your point of view was in clipA itself -- because, for example,
that's where you were writing your ActionScript -- then you could reach link
merely by typing ...

link

.... because clipA can "see" link right there inside itself. If your
ActionScript is in the _root, then you could simply type ...

clipA.link

.... no need to write "_root" beacuse you're *in* the root.

Does that clarify it?

[quoted text, click to view]

So far, same thing.

[quoted text, click to view]

Okay, still the same.

[quoted text, click to view]

All right. Again, you're telling a button what to do when someone
clicks on it, then releases. I think you understand that part. Next,
you're telling the button to look outside its own self and look, instead, to
the _root, where it should find a variable named link. If that variable's
value is not 9, do something.

The "do something" it's going to do is comprised of three things:

1) tell the _root timeline to go to a frame labeled "w2" and play
2) set the value of a variable named link in the _root to 9
3) set the value of a variable named page in the _root to the value of
_root.link, which we just established (step 2) as 9

Frankly, why not just set both _root.link and _root.page to 9? You
could do that all in one line.

_root.link = _root.page = 9;

Ehh, either way, it accomplishes the same thing.

[quoted text, click to view]

Well, there's nothing here that goes anywhere except a frame labeled
"w2". Maybe that frame has additional ActionScript?

[quoted text, click to view]

That would work.

[quoted text, click to view]

Movie clip symbols in your Library are not related to variables in the
main timeline. _root.link isn't a thing that occurs naturally in Flash.
The creators of this template decided to create a variable that holds
numbers. They named this variable "link" and put it in the main timeline.

When you ask "how would i give it a lable," I don't know what the "it"
of that question is. Do you mean "How do I get a movie clip symbol a
label?" What are you asking?

[quoted text, click to view]

It shouldn't, at this point, right? _root is just a way to tell
ActionScript where a variable is (or actually, where anything is). If
something is in the main timeline, then you can use _root in front of its
name to indicate where it is.

In general, though, it sounds like there's a handful of basics you
haven't worked through yet. Rather than continuing on in your template, I
strongly recommend you put that aside -- just for the time being -- and
familiarize yourself with the essential Flash terms. Look up _root and
_parent and "this" and the "MovieClip class" entry in the ActionScript
Language Reference. Start a brand new FLA and get your feet wet before
jumping in the deep end. ;)


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: _root.link = action script help! hennryflash
3/15/2006 10:23:28 PM
hi thanks for the quick reply.

its been a long day so im not explaining this aswell as i could, sorry!


on my main time time i have a button with this action :


on (rollOver){
gotoAndPlay("s1");
}
on (rollOut){
gotoAndPlay("s2");
}
on (release) {
if (_root.link <> 8) {
_root.gotoAndPlay("w2");
_root.link = 8;
_root.page = _root.link;

}
}


i understand the first part of the script but the _root stuff is new to
me.



ok what i have in mind is to create a new button on my time line, with a
similar action (in the one below i have just changed the number to 9 as example)

on (rollOver){
gotoAndPlay("s1");
}
on (rollOut){
gotoAndPlay("s2");
}
on (release) {
if (_root.link <> 9) {
_root.gotoAndPlay("w2");
_root.link = 9;
_root.page = _root.link;

}
}




now on my template the original action script
on (release) {
if (_root.link <> 8) {
_root.gotoAndPlay("w2");
_root.link = 8;
_root.page = _root.link;

}
}

sends you to a flash movie called "abous us"


what i had in mind was to duplicate that movie int the libary and call it, say
"about us 2"
then change the content.

now how would i either find out what rootlink or page that movie is? or how
would i give it a lable to link it to a button?

sorry if ive not explained my self again, but the root in action script has
challenged me, i could do it another way, but id like to understand this as it
looke very usefull.

cheers h
AddThis Social Bookmark Button