7 Replies Latest reply on Jul 20, 2013 6:06 PM by YOSHIOKA Ume

    Go to next label or previous label

    edwinmerced Level 1

      Is there an action in Animate to play next label or stop at  previous label?

       

      Thanks for any support.

       

      Att.,

       

      Edwin

        • 1. Re: Go to next label or previous label
          jbowden Adobe Employee

          There's not a specific action to do exactly that, no.

           

          However, you can put all your labels into an array, and then iterate through them to go to next/previous labels, such as how you'd do it in Flash.

          1 person found this helpful
          • 2. Re: Go to next label or previous label
            AMULI Level 4

            Hi edwin,

             

            An example of slider with previous and next buttons here : http://forums.adobe.com/message/5521947#5521947

             

            Gil

            • 3. Re: Go to next label or previous label
              YOSHIOKA Ume Level 3

              Hi, guys.

               

              It's not a formal , but there is also such a way.

              The label information, can be accessed in the "Default Timeline" via.

              console.log(sym.timelines['Default Timeline'].labels);
              

              So, use this, We can extend the Edge-Symbol. like this.

              //document.compositionReady
              
              //get label index for the time
              Symbol.prototype.getLabelID = function(time){
                time = time||this.getPosition();
                time = Math.max(time,1);
                //mapping the label name & time
                var ex = this.ex = this.ex||{};
                if(!ex.labels){
                  ex.labels = [{time:0,name:'start'}];
                  if(this.timelines['Default Timeline'].labels){
                    $.each(
                      this.timelines['Default Timeline'].labels,
                      function(key,val){ex.labels.push({time:val,name:key});}
                    );
                  }
                  //sort by time
                  ex.labels.sort(function(a,b){return (a.time<b.time)?-1:(a.time>b.time)?1:0});
                }
                //serch the label index
                for(var i=1;i<ex.labels.length;i++){
                  if(time<ex.labels[i].time)break;
                }
                return i-1;
              };
              
              Symbol.prototype.getNextLabelTime= function(time){
                var id =this.getLabelID(time);
                var labels = this.ex.labels;
                //return labels[Math.min(++id,labels.length-1)].time;
                return labels[++id%labels.length].time; // case loop
              }
              Symbol.prototype.getPrevLabelTime= function(time){
                var id =this.getLabelID(time);
                var labels = this.ex.labels;
                //return labels[Math.max(--id,0)].time;
                return labels[(--id+labels.length)%labels.length].time; // case loop
              }
              Symbol.prototype.nextLabel=function(play){
                var func =(play)?this.play:this.stop;
                func.call(this,this.getNextLabelTime());
              };
              Symbol.prototype.prevLabel=function(play){
                var func =(play)?this.play:this.stop;
                func.call(this,this.getPrevLabelTime());
              };
              

               

              In this. We can use prevLabel/nextLabel method.

               

              //move to next label

              sym.nextLabel();

              sym.getSymbol("Symbol_1").nextLabel();

               

              //move to prev label and play

              sym.prevLabel(true);

               

              etc..

               

              Because it extends the Edge-Symbol on its own, It's not the way "well-behaved".

              If you are interested, try .

               

              thanks.

              Ume.

              1 person found this helpful
              • 4. Re: Go to next label or previous label
                AMULI Level 4

                Hi Ume,

                 

                That's great ! Highly preferable to get the list of labels by code instead of hard-coding it in an array.

                 

                Gil

                • 5. Re: Go to next label or previous label
                  resdesign Adobe Community Professional & MVP

                  Yoshi, looks cool. I will try it in my next project!

                  • 6. Re: Go to next label or previous label
                    heathrowe Most Valuable Participant

                    Snazzy

                     

                    Darrell

                    • 7. Re: Go to next label or previous label
                      YOSHIOKA Ume Level 3

                      thx, thx ARIGATOU.

                       

                      Ume.