9 Replies Latest reply on Feb 22, 2014 3:07 AM by AMULI

    One symbol... different actions at different times

    jaceman Level 1

      Is there a way to assign an action to a symbol at one point in the timeline, and then a different action to the SAME symbol at a different place in the timeline (like I used to do with Flash)?

       

      I have an interactive floorplan I'm working on, and the same button that turns on a feature also needs to be able to turn it off.

       

      Many thanks for anyone's help with this.

        • 1. Re: One symbol... different actions at different times
          resdesign Adobe Community Professional & MVP

          Yes. You can have several labels in the symbol's timeline and several labels on the main timeline and then you can call the symbol timeline different labels from the main timeline.

          You could also have some conditional statements to play the symbol's timeline.

          I am sure there is a number of ways to do it.

          1 person found this helpful
          • 2. Re: One symbol... different actions at different times
            AMULI Level 4

            Hi Jaceman2,

            the same button that turns on a feature also needs to be able to turn it off.

             

            Your main timeline will have different states. You can get the current one with sym.getPosition(), which returns a position in ms (a getCurrentLabel() feature, as we are used to in Flash, would be useful here, but it is missing in Edge for now).

             

            Your button's click event handler then has a conditional statement, as pointed by Resdesign, the condition being this position value.

             

            A working example of such a conditional statement based on position here : http://forums.adobe.com/thread/1204999?tstart=0

             

            Gil

            • 3. Re: One symbol... different actions at different times
              claycalv

              Could you actually paste the code that would get this to work? I am more on the creative end, less development, and don't know the type of Javascript commands that would get this to work.

              • 4. Re: One symbol... different actions at different times
                AMULI Level 4

                Hi claycalv,

                 

                Say your main timeline has tree labelled points state1, state2 and state3.

                 

                click event handler for the button :

                 

                var mainTimeline = sym.getComposition().getStage();

                var currentPos = mainTimeline.getPosition();

                switch (currentPos)

                {

                  case mainTimeline.geLabelPosition( "state1") :

                     // do whatever you need to do in state 1

                    break;

                  case mainTimeline.geLabelPosition( "state2") :

                     // do whatever you need to do in state 2

                    break;

                  case mainTimeline.geLabelPosition( "state3") :

                     // do whatever you need to do in state 3

                }

                 

                Gil

                • 5. Re: One symbol... different actions at different times
                  AMULI Level 4

                  > I'm creating an image slider, where instead of fade-ins and fade-outs between images,

                  > the separate images in the slider literally slide into place at the center of the screen,

                  > and stop there. Underneath there are individual pagers for each photo, so that

                  > depending on which pager you click on, it will slide to the corresponding photo.

                   

                  (strangely, I received your message but it has vanished from the thread !)

                   

                  Please refer to the thread pointed to in post #2. At the end, you'll find a link to download PLAY_TO which is exactly the structure you're looking for. You got the logic : adapt it to your needs.

                   

                  Gil

                  • 6. Re: One symbol... different actions at different times
                    claycalv Level 1

                    Wow that is so excellent! Thank you! I've been trying to understand Javascript a little bit better so I will analyze this file and all of it's components. You're the best!

                     

                    PS - Yeah that's pretty strange, I guess someone deleted it? lol

                    • 8. Re: One symbol... different actions at different times
                      claycalv Level 1

                      One edit I have is that if you are already on 1, and press the first button, you want nothing to happen, so the code should be this:

                       

                      sym.getComposition().getStage().setVariable("currentLabel", "1");

                      var symbNumb = sym.getSymbol("numbers-1");

                      var position = symbNumb.getPosition();

                      if ( position < 0)

                      {

                        symbNumb.stop();

                      } else if ( position > 0) {

                        symbNumb.playReverse();

                      }

                      • 9. Re: One symbol... different actions at different times
                        AMULI Level 4

                        Hi claycalv,

                         

                        An important point to note is that : until a symbol hasn't played (it's autoplay property was set to false), nor its playhead has jumped elsewhere from 0 ms, sym.getPosition() returns -1.

                         

                        I just looked at the two files in the ZIP : unexpectedly, playToLabel1 is the first version, working only forward (play()) ; playToLabel is the second version, working both forward and backward (play() and playReverse()).

                         

                        You don't need to code symbNumb.stop(); because it's already coded in the triggers. For example, the second one, at 500 ms :

                         

                        if (sym.getParentSymbol().getVariable("currentLabel")=="2")

                        // if the "numbers" timeline is at label "2" (information in a global variable)

                        {

                          sym.stop();

                        }

                         

                        You don't even need this code for the first one (notice that the first trigger at 0 ms has been commented out), because back to 0 ms it will naturally stop.

                         

                        Gil