hennryflash,
[quoted text, click to view] > hi thanks for the quick reply.
:)
[quoted text, click to view] > its been a long day so im not explaining this aswell as i
> could, sorry!
No worries.
[quoted text, click to view] > on my main time time i have a button with this action :
>
>
> on (rollOver){
> gotoAndPlay("s1");
> }
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] > on (rollOut){
> gotoAndPlay("s2");
> }
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] > on (release) {
> if (_root.link <> 8) {
> _root.gotoAndPlay("w2");
> _root.link = 8;
> _root.page = _root.link;
> }
> }
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] > i understand the first part of the script but the _root
> stuff is new to me.
_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] > 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");
> }
So far, same thing.
[quoted text, click to view] > on (rollOut){
> gotoAndPlay("s2");
> }
Okay, still the same.
[quoted text, click to view] > on (release) {
> if (_root.link <> 9) {
> _root.gotoAndPlay("w2");
> _root.link = 9;
> _root.page = _root.link;
> }
> }
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] > 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"
Well, there's nothing here that goes anywhere except a frame labeled
"w2". Maybe that frame has additional ActionScript?
[quoted text, click to view] > what i had in mind was to duplicate that movie int the libary
> and call it, say "about us 2" then change the content.
That would work.
[quoted text, click to view] > 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?
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] > sorry if ive not explained my self again, but the root in
> action script has challenged me,
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."