Tween Timing Issue


i have script places text outside stage (based on words in array), , tweens them across stage (and repeats). problem words have varying widths, 1 tween/words, bumps another. trying find way have them move across 1 after another, @ consistant speed without bumping each other. sadly math not strong suite cant seem figure out. can body better math skills :]

 

(ned: if happen see , answer this..thanks...the script below prompted last forum question...didn't have written yet provide)

 

import mx.transitions.tween;

import mx.transitions.easing.*;

 

 

var adwords:array = new array("catalogued ", "retrieved ", "systematized ", "word 4 ", "word 5 ", "word 6 ", "word 7 ", "word 8 ", "word 9 ", "word 10 ");

var adwords_tf:array = new array()

var textholder:movieclip = new movieclip();

var moveword:tween;

var n:number = 0;

var i:number= 0;

//load adwords onto stage (off-satge)

for(i=0; < adwords.length; i++)

{

          var word = this.createtextfield("actionword_"+i, this.getnexthighestdepth(),0, 0, 0, 0)

          word.text = adwords[i];

          word.autosize = "left";

          format = new textformat();

          format.color = 0xcc1e2c;

          format.size =24;

          format.font = "folio";

          word.settextformat(format);

          word._x = - word._width

          adwords_tf.push(word)

 

}

tweenwords();

 

 

function tweenwords():void

{

          var moveword = new tween(adwords_tf[n], "_x", none.easenone, (0-adwords_tf[n]._width), stage.width, 5, true);

          moveword.onmotionchanged = function()

          {monitortweens ()}

}

 

 

 

 

function monitortweens ()

{

          onenterframe = function ()

                    {

                              if (n !== adwords_tf.length)

                              {

                                        if (adwords_tf[n]._x >= 0)

                                        {

                                                  n++

                                                  tweenwords()

                                        }

                                        delete onenterframe;

                              }

                              else

                              {

                                        n=0

                                        delete onenterframe;

                                        tweenwords()

                              }

 

                    }

 

 

}

the reason words not holding place in line because have distance must travel varying based on length has happen in same amount of time each.

 

say have word 100 pixels wide , 400 pixels wide.  both of them have travel tween in 5 seconds, longer word has cover more ground due having 300 more pixels travel... has travel faster.

 

so need level playing field each word has cover same amount of ground... travel @ same speed. can adjust end point of tween account length of word, start point...

 

var moveword = new tween(adwords_tf[n], "_x", none.easenone, (0-adwords_tf[n]._width), stage.width-adwords_tf[n]._width, 5, true);

 

 

but have words dropping off before end of stage.  if want them make full journey, you'll need adjust stage dimension factor of end point well.  adjustment matter of trial , error...

 

var moveword = new tween(adwords_tf[n], "_x", none.easenone, (0-adwords_tf[n]._width), stage.width+400-adwords_tf[n]._width, 5, true);



More discussions in ActionScript 1 and 2


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account