I don't agree with flashing the gun, but at the same time, asking for trouble is continuing to do it after they realize it's a cop and he's asked them to stop. To continue doing it is not just disrespectful, it's stupid and, by law, assault of a police officer.
They could have technically been charged with felonies over that stunt. While that would not have been justified, they definitely deserved to be taken in and slapped with a misdemeanor so perhaps they'll learn respect.
And I don't care where they learned it, it's wrong, it's disrespectful and it's unlawful. It's time they're taught some manners.