there's a little difference
afraid to (do): for things that are intentionally, you can choose to do them or not ''James was afraid to tell his parents what had happened''
afraid of (doing): for things that can happend like an accident '' I don't like dogs, I'm always afraid of being bitten''