• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Please help me add a gotoandstop function to the end of mytimer

Community Beginner ,
Jul 04, 2019 Jul 04, 2019

Copy link to clipboard

Copied

Please help me create a go to and stop (Frame)

function to the end of my timer!?

I'm struggling - tried everything

My script is below

countDown1F(00,50,50000,tf1);

function countDown2F(nStart:int,nEnd:int,duration:uint,tf:TextField) {

  if (nStart>=nEnd) {

  return null;

  } else {

  var t:Timer = new Timer(duration/(nEnd-nStart),nEnd-nStart);

t.addEventListener(TimerEvent.TIMER,function(e:TimerEvent){f2(e,nEnd,tf)});

  t.dispatchEvent(new TimerEvent(TimerEvent.TIMER));

  t.start();

  }

}

function f2(e:TimerEvent,nEnd:int,tf:TextField){

 

}

function countDown1F(nStart:int,nEnd:int,duration:uint,tf:TextField) {

  if (nStart>=nEnd) {

  return null;

  } else {

  var t:Timer = new Timer(duration/(nEnd-nStart),nEnd-nStart);

t.addEventListener(TimerEvent.TIMER,function(e:TimerEvent){f1(e,nEnd,tf)});

  t.dispatchEvent(new TimerEvent(TimerEvent.TIMER));

  t.start();

  }

}

function f1(e:TimerEvent,nEnd:int,tf:TextField){

  tf.text = formatF( (nEnd-e.target.currentCount));

}

function formatF(n:int):String {

var min:int = Math.floor(n/60);

var sec:int = n-min*60;

var a:Array = [min.toString(),sec.toString()];

for (var i:uint=0; i<a.length; i++) {

  while (a.length<2) {

  a="0"+a;

  }

}

return a[0] + ":" + a[1];

}

TOPICS
ActionScript

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 5 Correct answers

Community Expert , Jul 05, 2019 Jul 05, 2019

var t:Timer;

var tf:TextField;

var nend:int;

countDown1F(00,50,50000,tf1);

function countDown1F(nstart:int,nend:int,duration:int,_tf:TextField):void{

if(nstart<nend){

tf=_tf;

t=new Timer(duration/(nend-nstart),nend-nstart);

t.addEventListener(TimerEvent.TIMER,timerF);

t.start();

}

}

function timerF(e:TimerEvent):void{

tf.text=formatF(nend-e.targer.currentCount);

if(e.currentCount==e.repeatCount){

gotoAndStop(wherever);  // assign wherever

}

}

function formatF(n:int):String {

var min:int = Math.floor(n/60);

var sec:

...

Votes

Translate

Translate
Community Expert , Dec 12, 2022 Dec 12, 2022

what's the trace output after 2 frame visits

 

trace(counter);

var counter:int;

if(counter){

counter++;

} else {

counter = 1;

}

 

Count.text = String(counter);

trace("tf",Count.text);

 

 

 

 

Votes

Translate

Translate
Community Expert , Dec 17, 2022 Dec 17, 2022

use

 

parent.gotoAndStop(2)

Votes

Translate

Translate
Community Expert , Feb 11, 2023 Feb 11, 2023

no, you would use

 

if(this.currentLabel== yourlabel){
count=0;

}

Votes

Translate

Translate
Community Expert , Feb 12, 2023 Feb 12, 2023

yourbutton.addEventListener("MouseEvent.CLICK,f);

 

function f(e:MouseEvent):void{

counter=0;

}

Votes

Translate

Translate
New Here ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

enable 2fa on your account.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

Hi Kglad - how would I make a end of movie clip have a gotoAndPlay function once the movie clip ends on a frame?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

Im trying to control the parent ( so its just a movie clip on the main timeline - ive entered the movie clip and on the last frame of the movie clip i put Parent.gotpAndPlay(2) but when I run Swf preview I get an erroe which says - 1061: call to possibly undefined method gotoandplay through a static reference"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

 case counts.  parent!= Parent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

case counts. Parent!= Parent. 

 

Parent.gotoAndStop(2);

 

This is what I put on the last frame of the movie clip and I got an error saying expecting identifier before case "

 

 

Im guessing ive wrote the code out wrong 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

use

 

parent.gotoAndStop(2)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

That did not work. Im not sure what Im doing wrong

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

on the main timeline use

 

trace('main', this)

 

and on the movieclip with goto put

 

trace('mc', this)

 

then test

 

copy and paste the output?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

LATEST

what's the trace output after 2 frame visits

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines