Combine sugar and cornstarch in a small saucepan; stir well. Add egg; stir well with a whisk until smooth. Add milk, stirring until smooth.
Stir constantly over medium heat 8 minutes until mixture thickens and comes to a boil. Remove from heat, and stir in butter and flavorings. Spoon mixture into a bowl and chill.