Flex Implementation of motion detection