Y
Y
Yuri Antonov2013-11-17 10:00:56
Adobe Flash
Yuri Antonov, 2013-11-17 10:00:56

How to insert a timer into a text field?

I have this code:

btn_play.addEventListener(MouseEvent.CLICK, playyer);
btn_stop.addEventListener(MouseEvent.CLICK, stopper);
var tiktak: String = "часики тикают";
var netik: String = "пауза";
current_txtf.text = tiktak;

function stopper (event:MouseEvent):void
{
  btn_stop.visible = false;
  btn_play.visible = true;
  current_txtf.text = netik;
  stop();
  }
  
function playyer (event:MouseEvent):void
{
  btn_stop.visible = true;
  btn_play.visible = false;
  current_txtf.text = tiktak;
  play();
  }

These are two play and pause buttons and text fields.
How to make a working timer instead of the inscription: the clock is ticking, and stop it when the stop button is pressed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
svd71_1, 2013-11-17
@Antonov_Yuriy

you need a procedure that will run from a timer or thread. I don’t really understand what kind of SP you have, but it looks like JavaScript.
For JS, you need to create a function that will increment the counter and output it to the field.
In playyer, instead of modifying a variable, you need to write code to start the setTimeout or setInterval timer. And in stopper you need to write a clearTimeout or clearInterval call. There are still nuances that the timer needs to be restarted again in its function. And it is even better to read the help with examples about these functions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question