Note that there are some explanatory texts on larger screens.

plurals
  1. POFlash restart functions after completion
    primarykey
    data
    text
    <p>I have made this code which works fine - my problem is that at the end i wish to make it start over.</p> <p>When i started making this my intent was, that the .swf movie would just loop when it ended - but that does not happen. Then i figured that i would try and make a sort of "restart" function in the code itself that would reset the timer and strings.. I have googled around and tried a couple of things myself - But to no luck at all..</p> <p>First i tried to reset the variable i. Then i tried to remove the timer eventListeners. But with no succes.</p> <p>What would be the best way to go about getting this code to start over again?</p> <pre><code>import flash.utils.Timer; import flash.events.TimerEvent; import com.greensock.*; import com.greensock.easing.*; var str_one:String = 'På fredag udkommer metroXpress, som du kender den, for sidste gang... '; var i:uint = 0; var timer_one:Timer = new Timer(50); timer_one.start(); timer_one.addEventListener(TimerEvent.TIMER, goTime); var str_two:String = 'På fredag udkommer metroXpress, som du kender den, for sidste gang... Fra 2. april bliver du mødt af en helt ny avis, med det bedste fra den gamle, tilsat en masse nyt.'; var timer_two:Timer = new Timer(50); timer_two.addEventListener(TimerEvent.TIMER, goTime_two); var str_three:String = 'På fredag udkommer metroXpress, som du kender den, for sidste gang... Fra 2. april bliver du mødt af en helt ny avis, med det bedste fra den gamle, tilsat en masse nyt.Sådan vil vi skabe en endnu bedre avis til dig, der er på farten. Glæd dig – det gør vi!'; var timer_three:Timer = new Timer(50); timer_three.addEventListener(TimerEvent.TIMER, goTime_three); function goTime(e:TimerEvent) { tekstbox1_txt.appendText(str_one.charAt(i)); i++; if (i&gt;=str_one.length) { timer_one.stop(); TweenLite.to(hand, 1, {y:175, onComplete:ripwhite}); } } function ripwhite():void { TweenLite.to(hand, 1, {y:405}); TweenLite.to(white_mask, 1, {y:320, onComplete:fadetekst1ud}); } function fadetekst1ud():void { TweenLite.to(tekstbox1_txt, 1, {alpha:0, onComplete:tekstnr2}); } function tekstnr2():void { timer_two.start(); } function goTime_two(e:TimerEvent) { tekstbox2_txt.appendText(str_two.charAt(i)); i++; if (i&gt;=str_two.length) { timer_two.stop(); TweenLite.to(tekstbox2_txt, 1, {alpha:1, onComplete:forsinkelse}); } } function forsinkelse():void { TweenLite.to(tekstbox2_txt, 1, {alpha:0, onComplete:tekstnr3}); } function tekstnr3():void { timer_three.start(); } function goTime_three(e:TimerEvent) { tekstbox3_txt.appendText(str_three.charAt(i)); i++; if (i&gt;=str_three.length) { timer_three.stop(); TweenLite.to(tekstbox3_txt, 1, {alpha:1, onComplete:sidstefunktion}); } } function sidstefunktion():void { TweenLite.to(tekstbox3_txt, 1, {alpha:0}); TweenLite.to(rippedpic, 1, {alpha:0}); } </code></pre> <p>EDIT:</p> <p>When setting up a reset function and then making it loop back to my initial function like this:</p> <pre><code>function nulstil():void { i = 0; TweenLite.killTweensOf(hand); TweenLite.killTweensOf(tekstbox1_txt); TweenLite.killTweensOf(tekstbox2_txt); TweenLite.killTweensOf(tekstbox3_txt); timer_one.addEventListener(TimerEvent.TIMER, goTime); timer_two.addEventListener(TimerEvent.TIMER, goTime_two); timer_two.addEventListener(TimerEvent.TIMER, goTime_three); TweenLite.to(white_mask, 0.1, {onComplete:goTimeAgain}); } </code></pre> <p>I get the following in the output:</p> <p>ArgumentError: Error #1063: Argument count mismatch on Untitled_fla::MainTimeline/goTimeAgain(). Expected 1, got 0. at Function/<a href="http://adobe.com/AS3/2006/builtin::apply()" rel="nofollow">http://adobe.com/AS3/2006/builtin::apply()</a> at com.greensock.core::TweenCore/complete() at com.greensock::TweenLite/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll()</p>
    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.
 

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