PDA

View Full Version : help on stopping a loop


tshelto
01-24-2008, 03:55 PM
I guess I will ask the questions in here. lol

Okay on my stage I have a start(MC) and a stop(MC) and a clear(MC) these will be used as buttons. I also have a dynamic text box that shows my output.

I am making it so when you click start it will starting counting from 0 to whenever you hit the stop button, I have changed my fps to 1 so it doesn't crash my computer, And this is where I am running into trouble. Here is my code.

var myTimer = 0;

startBtn.onPress = function() {
this.onEnterFrame = function() {
myTimer = myTimer + 1;
//trace(myTimer);
this._parent.myTxt.text = myTimer;
}

}


stopBtn.onPress = function() {
trace(myTimer);
this.myTimer.onEnterFrame = stop();
}


I would also like it so when you hit start again it picks up where it left off.

Please any help would be greatly appreciated.

Thanks
T

Paul C
01-24-2008, 07:54 PM
Believe me I am no Flash script expert but I did used to code.

Don't you need another variable that holds the current value of myTimer? It seems like this code would reset myTimer every time to 0. Another variable could hold the current value and be used instead where you wanted it.

But that is a very uneducated guess.

pbc