Archive for March, 2010

Getting Around Onload in Flash

Friday, March 5th, 2010

I’ve been doing some Flash work recently and ran into a conundrum. You can’t create an empty movie clip, load a movie in it, and do a movie.onload=function(){...}. There are lots of work arounds, but here’s the one I just came up with that I liked.

function loadMyMovie(clipName, depth, loadInClip, funcbefore, funcafter) {
	var watchLoad = function() {
		if(_root[clipName].getBytesLoaded() == _root[clipName].getBytesTotal() && _root[clipName].getBytesTotal() > 0) {;
		} else {
	_root.createEmptyMovieClip(clipName, depth);

funcbefore and funcafter should be the functions that show and hide your loading message.

I haven’t tested this exact bit of code, but that’s the basic principle.