18 Replies Latest reply on Jan 26, 2010 7:26 AM by kglad

    xml % controlling timeline

    DigiFront

      Hi there

       

      Well, I have a project where I would need a XML with a % range from 0-100 to controll a timeline. The concept is to fill a bottle. So the timeline would animate from empty to full. But must be controlled with a XML number and its all in AS2....

       

      Any suggestions?

        • 1. Re: xml % controlling timeline
          kglad Adobe Community Professional & MVP

          the xml would supply a static number.  how would that work?  do you want to display one frame of a movieclip with that one frame determined by the xml data?

          1 person found this helpful
          • 2. Re: xml % controlling timeline
            kglad Adobe Community Professional & MVP

            forum test.

            • 3. Re: xml % controlling timeline
              DigiFront Level 1

              thanks for coming back so quickly!

               

              Well.... The xml for instance would be:

               

              <title>

                   <bottle 1>

                        <amount>15%</amount>

                   </bottle 1>

              </title>

              <title>

                   <bottle 2>

                        <amount>50%</amount>

                   </bottle 2>

              </title>

               

              And hope to have 2 bottles with a movieclip that animates to the desired %....

              • 4. Re: xml % controlling timeline
                kglad Adobe Community Professional & MVP

                that xml would indicate you want to play from about 15% of a movieclip's timeline to about 50% of its timeline?

                1 person found this helpful
                • 5. Re: xml % controlling timeline
                  DigiFront Level 1

                  I see....

                   

                  So I guess one would need to have a loadMovie function to control 2 seperate movie clips? Could the XML still control seperate timelines?

                  • 6. Re: xml % controlling timeline
                    kglad Adobe Community Professional & MVP

                    no.

                     

                    i wasn't making a statement.  i was asking a question.

                     

                    i'm trying to understand exactly what you want that xml to do.

                    • 7. Re: xml % controlling timeline
                      DigiFront Level 1

                      Oh! oops....

                       

                      Well the xml will have a set of percentages on it ranging from 0% - 100% for 19 different bottles. The bottles would animate to the % that is allocated on the xml as it would updated at another point in time. So if bottle one is currently at 0%, when one updates the xml, bottle 1 could be 23% or 43%? it would be a random guess. So the flash file could be updated on the fly.

                      • 8. Re: xml % controlling timeline
                        DigiFront Level 1

                        here is a basic concept unanimated but the "water" would animate on the timeline to the % set on the XML file....

                        • 9. Re: xml % controlling timeline
                          kglad Adobe Community Professional & MVP

                          you undestand the xml is static, correct?  the xml might indicate bottle 1 should animate from startPCT to endPCT but that would occur any time you wanted, after the xml is loaded.

                           

                          the xml will probably not, at some later time, indicate bottle 1 should animate to another pct.

                           

                          so, you want to read in this xml file and animate all 19 bottles filling from whatever startPCT to endPCT that's indicated in the xml file for that bottle.  ie, you'll have 19 bottles filling at the same time.

                          • 10. Re: xml % controlling timeline
                            DigiFront Level 1

                            Yes that would be correct!

                             

                            I see what you mean that the XML is static and you are right in that the bottles would all fill together on load.

                            • 11. Re: xml % controlling timeline
                              kglad Adobe Community Professional & MVP

                              if you have bottle movieclips, bottleMC_1, bottleMC_2,...,bottleMC_19,  you can use:

                               

                              var bottleFillA:Array = [];
                              var tl:MovieClip = this;

                               

                              var xml:XML = new XML();
                              xml.ignoreWhite = true;
                              xml.onLoad = parseXML;
                              xml.load("bottles.xml");

                               

                              function parseXML(){
                                  for(var i:Number=0;i<this.firstChild.childNodes.length;i++){
                                      bottleFillA.push(this.firstChild.childNodes[i].firstChild.firstChild.nodeValue.split("%") .join(""));
                                  }
                                  initF();
                              }

                               

                              function initF(){
                                  for(var i:Number=0;i<bottleFillA;i++){
                                      tl["bottleMC_"+i].pct = bottleFillA[i]/100;
                                      tl["bottleMC_"+i].onEnterFrame = animateF;
                                  }
                              }

                               

                              function animateF(){
                                  this.nextFrame();
                                  if(this._currentframe>=this._totalframes*this.pct){
                                     delete this.onEnterFrame;
                                  }
                              }

                               

                              ////////////////////////////////////////////////////////

                              where your xml is:

                               

                              <bottles>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>50%</amount>
                                  </bottle>
                                  <bottle>
                                      <amount>15%</amount>
                                  </bottle>
                              </bottles>

                              • 12. Re: xml % controlling timeline
                                DigiFront Level 1

                                Wow!!! ok that is quite a bit! thanks!

                                 

                                Just checking, would the movieclips be animated to 100 frames within themselves or would the main timeline be 100 frames?

                                • 13. Re: xml % controlling timeline
                                  DigiFront Level 1

                                  Hi Kglad

                                   

                                  I have tried animating the movie clips from frame 1 - 100, the timeline from 1-100 and even just leaving them without any animation? Please excuse my slow grasp of this. I guess it is quite straight forward.

                                   

                                  But if you have a final soultion for the above. And really appreciate your time!

                                  • 14. Re: xml % controlling timeline
                                    kglad Adobe Community Professional & MVP

                                    each bottle movieclip would be animating.  the movieclips don't necessarily have to have 100 frames.

                                     

                                    each bottle movieclip must have instance name, bottleMC_1 etc on the same timeline that contains that code.

                                     

                                    and, your xml file have the same structure as the one i suggested.  of course, you can change that numbers that specify the percent.

                                     

                                    if that doesn't work for you, show your code and your xml (even if it's exactly the same as i posted).

                                    • 15. Re: xml % controlling timeline
                                      DigiFront Level 1

                                      here is a reference of the great script you gave me:

                                       

                                      • I have made 2 bottles, just basic tweens called bottleMC_1 and 2.
                                      • I have attached the xml file you made up to.

                                       

                                      There seems to be a issue when exporting it as it doesn't read the section of the script to only animate to the % that is given in the xml?

                                       

                                      Thanks for your help again!

                                      • 16. Re: xml % controlling timeline
                                        kglad Adobe Community Professional & MVP

                                        my mistake:

                                         

                                        function initF(){
                                            for(var i:Number=0;i<bottleFillA;i++){
                                                tl["bottleMC_"+i].pct = bottleFillA[i]/100;
                                                tl["bottleMC_"+i].onEnterFrame = animateF;
                                            }
                                        }

                                         

                                        //should be:

                                         

                                        function initF(){
                                            for(var i:Number=0;i<bottleFillA.length;i++){
                                                tl["bottleMC_"+i].pct = bottleFillA[i]/100;
                                                tl["bottleMC_"+i].onEnterFrame = animateF;
                                            }
                                        }

                                        • 17. Re: xml % controlling timeline
                                          DigiFront Level 1

                                          Hi there!

                                          It works beautifully! Thanks!

                                           

                                          It comes up like it should! much appreciated!

                                          • 18. Re: xml % controlling timeline
                                            kglad Adobe Community Professional & MVP

                                            you're welcome.