programming code using Actionscript 3.0

can some one guide for programming code for velocity with variable time and distance in Actionscript 3.0

Are you basically looking for a function that divides distance by time? :thinking:

Yes, variables are distance and time. trying on Actionscript 3,0
Following is not working, getting an error as Velocity is Nan km/hr
var velocity:Number;
velocity = distance / time;
lblOutput.text = “The velocity is: " + velocity.toFixed(1) + " km/h.”;
var distance:Number;
var time:Number;

Looks like time is 0 or undefined, so you’re going to get NaN as a result of your division. You’ll need to pick a time value and move that code above the line where you assign to lblOutput.text.

Good luck!

To add to what krilnon said, i now always cast my numbers as 0 to start. I used to get random NAN outputs only to find i had pulled from a number that didnt yet exist.