Millis() / Unsigned long subtraction not working

what are these?

why are "flags" needed? why not monitor a sensor and perform some action based on a sensor value?