something like this:

my.frame = distance / max_distance * 10; //max_distance = 300