Fenrir370 0 Newbie Poster

so i have a class assignment to link all our game files, im trying to load a "lose.swf" after the car crashes. our teacher only gave us this line of code to use and i cant seem to figure out how to get the MovieClip(stage.getChildAt(0)).loadThisScreen("lose.swf");
part to work properly ( we did not learn flash coding we just learned to animation part ) but from my c++ class i can kinda understand whats going on.

import ash.net.URLRequest;
// Creating the loader ----------------------------------------------------/
var loader:Loader = new Loader();
loader.load(new URLRequest("homeScreen.swf")); // adding your homeScreen
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
// Function that loops variables for percent loaded text and scaling the progress bar -----------------------------------/
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
var s:String = Math.ceil(perc*100).toString()+"%";
percent_txt.text = s;
bar_mc.scaleX = perc;
}
//Unloading the loader and removing the pre-loader elements --------------/
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
function done(e:Event):void
{
removeChildAt(getChildIndex(percent_txt));
removeChildAt(getChildIndex(gear_mc));
removeChildAt(getChildIndex(bar_mc));
// nally, add the loader to the stage to display it ------------------------------------/
stage.addChild(loader);
}
function loadThisScreen(screen:String):void
{
 loader.unloadAndStop();
 loader.load(new URLRequest(screen));
 addChild(percent_txt);
 addChild(bar_mc);
}
// Code that goes on the end of the crash frame ------------------------------------/
MovieClip(stage.getChildAt(0)).loadThisScreen("lose.swf");
// Code that goes on the last frame of the main timeline when you win ------------------------------------/
MovieClip(stage.getChildAt(0)).loadThisScreen("win.swf");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.