2 Replies Latest reply on Jan 18, 2010 2:06 PM by Ned Murphy

    Disecting a piece of AS

    misterbigglesworth

      I'm trying to simplify a button.

       

      Can someone tell me which of the following lines of code pertain to *where* in the timeline you are taken upon release?

       

      on (release) {
          if (_root.link<>_parent.num) {
              if (_root.rp<>1) {
                  _root.scroller.gotoAndStop("s0");
                  _root.lcont = _root.link;
                  _root["item"+_root.link].gotoAndPlay("s2");
                  _root.rp = 1;
                  _root.link = _parent.num;
                  _root.gotoAndPlay("s1");           
              }}}

        • 1. Re: Disecting a piece of AS
          RossRitchey Level 4

          I'll take a stab at it via comments at the end of each line:

           

          on (release) { //when you click and then release the mouse on this object
              if (_root.link<>_parent.num) { // if the variable "link" on the root timeline <> the variable "num" on the timeline of the parent of this object
                  if (_root.rp<>1) { // if the var "rp" on the root timeline <> 1
                      _root.scroller.gotoAndStop("s0"); // the object "scroller" on the root timeline -> go to and stop at the frame "s0"
                      _root.lcont = _root.link; // the var "lcont" on the root timeline = the var "link" also on the root timeline
                      _root["item"+_root.link].gotoAndPlay("s2"); // the object named "link"+_root.link (IE, if _root.link = "abcd" the object would be called "linkabcd" -> go to and play the frame "s2"
                      _root.rp = 1; // the var "rp" on the root timeline = 1
                      _root.link = _parent.num; // the var "link" on the root timeline = the var "num" on the parent to this objects timeline
                      _root.gotoAndPlay("s1"); // the root timeline -> go to and play the frame "s1"
                  }
               }
          }
          

           

          The root timeline is a keyframe on the main timeline of the FLA. This frame will have an "a" in it.

          • 2. Re: Disecting a piece of AS
            Ned Murphy Adobe Community Professional & MVP

            Since travel is a hierarchical thing, and the _root travels in this scenario, that most likely defines where you have traveled to when it executes.  So on release you end up starting to play at a frame labeled "s1", but that only happens if the two conditionals each produce a true result.