dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] Simple button gotoAndStop command...

  1. #1
    wiggle your jiggle TrytoAnimate's Avatar
    Join Date
    Sep 2000
    Location
    Rhode Island, USA
    Posts
    149

    [F8] Simple button gotoAndStop command...

    I seem to be having the hardest time making a movieclip instance tell another movie clip instance to gotoAndStop on a certain frame label via mouseclick. I've done this before easily, but for some reason the code isn't working this time. Here's what I have for actions:

    stop();

    // these actions work correctly

    aboutMyself.onRollOver = over;
    aboutMyself.onRollOut = out;

    education.onRollOver = over;
    education.onRollOut = out;

    family.onRollOver = over;
    family.onRollOut = out;


    function over() {
    this.gotoAndStop("over");
    }
    function out() {
    this.gotoAndPlay("out");
    }

    // these actions are not working correctly

    this.aboutMyself.onRelease = function() {
    this.aboutMeNav.gotoAndStop("about");
    }

    this.education.onRelease = function() {
    this.aboutMeNav.gotoAndStop("edu");
    }

    this.family.onRelease = function() {
    this.aboutMeNav.gotoAndStop("fam");
    }

    aboutMeNav is the movie clip I'm trying to direct. The first set of functions are making the movie clips act as rollover buttons, and the second set are giving them the action to do their job. Am I going crazy?
    Attached Files Attached Files

  2. #2
    Senior Mamba austriaman's Avatar
    Join Date
    Aug 2004
    Location
    Somewhere over the rainbow
    Posts
    472
    Remove this from your code.

    code:
    aboutMyself.onRelease = function() {
    aboutMeNav.gotoAndStop("about");
    }

    education.onRelease = function() {
    aboutMeNav.gotoAndStop("edu");
    }

    family.onRelease = function() {
    aboutMeNav.gotoAndStop("fam");
    }


  3. #3
    wiggle your jiggle TrytoAnimate's Avatar
    Join Date
    Sep 2000
    Location
    Rhode Island, USA
    Posts
    149
    That worked, thanks! I'm a little confused though, I thought whenever you were having 1 movie clip tell another to do something, you needed "this" in front of it?

    Thanks for the help

  4. #4
    Amazed and Amused Mazoonist's Avatar
    Join Date
    Mar 2006
    Location
    Northern California
    Posts
    201
    Hey, TryToAnimate,

    Can I help you with an explanation? In the following:
    Code:
    this.aboutMyself.onRelease = function() {
          this.aboutMeNav.gotoAndStop("about");
    }
    The word "this" in the first line means the main timeline. So the line is saying "look in the current timeline for a button or movie clip called aboutMyself and attach the following onRelease function to it."

    Inside the curly braces, though, "this" means something else entirely. Since you're defining a function for this.aboutMyself, inside the curly braces, "this" refers to the "aboutMyself" movie clip. So the line inside is really saying:
    aboutMyself.aboutMeNav.gotoAndStop("about");
    Since there's no aboutMeNav inside of the aboutMyself button, that's why it doesn't work.

    Removing "this" works, because now flash will assume the current timeline. However, if you wanted to really understand the correct path, it would be like this:
    this._parent.aboutMeNav.gotoAndStop("about");

    Once you realize that "this" is referring to the "aboutMyself" movie clip, then this._parent means one level up from that, or the main timeline.

  5. #5
    Senior Mamba austriaman's Avatar
    Join Date
    Aug 2004
    Location
    Somewhere over the rainbow
    Posts
    472
    It's sometimes a good idea to work with absolute paths. Absolute paths always emanate from the root-timeline (hence: _root):
    code:
    _root.aboutMyself.onRelease = function() {
    _root.aboutMeNav.gotoAndStop("about");
    }
    // etc. ...

    It's just a matter of preference really.

  6. #6
    wiggle your jiggle TrytoAnimate's Avatar
    Join Date
    Sep 2000
    Location
    Rhode Island, USA
    Posts
    149
    Ahh, thank you both for clearing that up for me... makes a lot more sense now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center