Maybe you could look at the code from the preloader Remus created.
There's one on his website in the KoolMoves / AS1 section
http://necromanthus.com/main.html