Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suggested in a comment that you use TimelineMax. Here's the full code that I think should work. Note carefully where I use the <code>offset</code> argument of <code>append</code> and where I don't. You'll need to fill out the <code>resetEverything</code> function to set all the visual elements to their proper starting positions, alphas, etc. </p> <p>Basically how this works: Instead of using <code>Timers</code> we use the <code>addCallback</code> feature of TimelineMax. Callbacks have "length" of 0 in the timeline, so you have to manually advance the playhead when you are attaching the callbacks, and when you add the first tween after each batch of callbacks (that's where we use the offset argument). Tweens do have a length, though, so subsequent calls to <code>append</code> will automatically align the tweens to the end of the timeline as built up to the that point. </p> <p>In the constructor of the TimelineMax we specified <code>repeat : -1</code>, which will cause the timeline to loop forever. Finally, we added the <code>resetEverything</code> callback at the very beginning so that every time the timeline restarts we are assured that all the elements are in the correct start position. The rest is completely automatic, handled by the timeline.</p> <pre><code>import com.greensock.*; var str_one:String = 'På fredag udkommer metroXpress, som du kender den, for sidste gang... '; var str_two:String = 'Fra 2. april bliver du mødt af en helt ny avis, med det bedste fra den gamle, tilsat en masse nyt.'; var str_three:String = 'Sådan vil vi skabe en endnu bedre avis til dig, der er på farten. Glæd dig – det gør vi!'; //-------- HELPER FUNCTIONS ---------// // Set everything to start positions function resetEverything():void { // Set alphas, positions, etc. hand.x = &lt;start x&gt;; hand.y = &lt;start y&gt;; // } // Quick reusable callback function addText(textBox:TextField, text:String):void { textBox.appendText(text); } //-------- BUILD THE TIMELINE ---------// var timeline:TimelineMax = new TimelineMax({repeat : -1}); //repeat = -1 --&gt; loop forever timeline.pause(); timeline.addCallback(resetEverything, 0); var lng:uint = str_one.length; var playHead:Number = 0.05; for(var i:uint = 0; i &lt; lng; i++) { timeline.addCallback(addText, playHead, [tekstbox1_txt, str_one.charAt(i)]); playHead += 0.05; } timeline.append(new TweenLite(hand, 1, {y:175}), lng * 0.05); // !!Note the offset argument here!! timeline.append(new TweenLite(hand, 1, {y:405})); timeline.append(new TweenLite(white_mask, 1, {y:320})); timeline.append(new TweenLite(tekstbox1_txt, 1, {alpha:0})); playHead += 4; lng = str_two.length; for(i = 0; i &lt; lng; i++) { timeline.addCallback(addText, playHead, [tekstbox2_txt, str_two.charAt(i)]); playHead += 0.05; } timeline.append(new TweenLite(tekstbox2_txt, 1, {alpha:1}), lng * 0.05); // !!Note the offset argument here!! timeline.append(new TweenLite(tekstbox2_txt, 1, {alpha:0})); playHead += 2; lng = str_three.length; for(i = 0; i &lt; lng; i++) { timeline.addCallback(addText, playHead, [tekstbox3_txt, str_three.charAt(i)]); playHead += 0.05; } timeline.append(new TweenLite(tekstbox3_txt, 1, {alpha:1}), lng * 0.05); // !!Note the offset argument here!! timeline.append(new TweenLite(tekstbox3_txt, 1, {alpha:0}); timeline.append(new TweenLite(rippedpic, 1, {alpha:0}); timeline.play(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload