function doLoadMovie(url, movie_name, path_arr) { trace("path_arr: "+path_arr); if (this.curr_movie != movie_name) { // If a movie is already loading, abort before loading the new one if (this.mediaLoad.isLoading()){ this.mediaLoad.stop(); this.mediaLoad.destroy(); this[curr_movie].removeMovieClip(); curr_movie = last_movie; } last_movie = curr_movie; curr_movie = movie_name; // create an empty mc for the movie we're loading var mc = this.createEmptyMovieClip(movie_name, this.getNextHighestDepth()); // add the new movie to the distribution, which will handle positioning this.distribution.removeItem(this[last_movie]); this.distribution.addItem(mc,1); this.distribution.positionItems(); this.mediaLoad = new MediaLoad(mc, url,true); // Add an event observer to display load progress this.mediaLoad.addEventObserver(this, MediaLoad.EVENT_LOAD_PROGRESS, "onMediaLoadProgress"); // prepare call to setPath() var seq:Sequence = new Sequence(false); seq.addTask( new FrameDelay(mc, "setPath", 0, path_arr) , "start", 0); // The chain will start the MediaLoad, then wait for an onEnterFrame event before calling this.loadMediaComplete() // We wait a frame because Flash is wierd like that // (See org.casaframework.time.FrameDelay Help for additional information) var chain:Chain = new Chain(false); // loads the file chain.addTask(this.mediaLoad, "start", MediaLoad.EVENT_LOAD_INIT); // waits 1 frame chain.addTask(this.pulseInstance, "start", EnterFrame.EVENT_ENTER_FRAME); // calls mc.setPath() chain.addTask(seq, "start", Sequence.EVENT_COMPLETE); // transition chain.addEventObserver(this, Chain.EVENT_COMPLETE, "loadMediaComplete"); chain.start(); } else { // Since this movie is the curr_movie, just call setPath this[movie_name].setPath(path_arr); } }