I think it is good for kids to have a sense of stranger danger. I am a believer in giving children their space, and they shouldn't be forced to give affection when they don't want to. I also let my son ignore strangers when they talk to him. It's hard to enforce "don't talk to strangers", but them make them to be polite to certain ones. I have even told people off who keep on talking to my son after I explain that he doesn't talk to strangers.

Anyway, your daughter sounds like she was having a normal, mature reaction to someone making her feel uncomfortable.