Just watch. This demonstrates how to automate a sprite to draw squares and stars, randomizing size and location each time.
To do a project like this you have to add the Pen extension.