Math: Total Distance according to Speed and Time
// Fort Canning Park Walkthrough : final semster project 2002
// user speed input
if (_root.input.text == "") {
speed = 1;
} else {
speed = _root.input.text;
//trace(speed);
}
// forward and rewind of mc
mcscene5.onEnterFrame = function() {
mousePos = _root._ymouse;
cfrm = _root.mcscene5._currentframe;
if (mousePos>0 && mousePos<175) {
_root.mcscene5.gotoAndStop(cfrm+speed/1);
} else if (mousePos>225 && mousePos<400) {
_root.mcscene5.gotoAndStop(cfrm-speed/1);
}
};
updateAfterEvent;
// Time
timevar = Math.round((getTimer()/1000));
tfrm = _root.mcscene5._totalframes;
// Distance
function distance() {
x = (Math.round((getTimer()/1000)*speed/6));
trace(x);
distvar = ++x;
updateAfterEvent;
}
if (mousePos>0 && mousePos<175 && cfrm>9 && cfrm<(tfrm-9)) {
distance();
} else if (mousePos>225 && mousePos<400 && cfrm>9 && cfrm<(tfrm-9)) {
distance();
}
The problem are those in bold text. My current does dosen't work. I want to work out the total distance travel taking into account the speed input by the user and the time. I only want the ticking of the time ( for the distance ) to start when the user is forwarding. And that the ticking of the distance meter will be faster when they put in a faster speed... slower when they put a smaller speed. My current method just dosen't work out so hopefully some Math guru can help me out here and give me a solution or just some hints to guide me? Thank you.