Bring sugar and water to a boil with star anise in a small heavy saucepan over medium heat, stirring until sugar has dissolved, then wash down any sugar crystals from side of pan with a pastry brush dipped in cold water. Boil, without stirring, swirling pan occasionally so caramel colors evenly, until pale golden. Carefully add vinegar, red-pepper flakes, and 1/8 teaspoon salt (caramel will spatter and harden). Continue to cook until sugar has dissolved.