Using LoadLevelAsync to load a level in the background , but initiate the level changing after something is done

I have an introductional video as the first level of my game.

As it plays , i want the menu level to be loaded in the background , but only change the level when the video is done playing. I currently have this which does not work.

var introVid:AsyncOperation;
var movieTexture:MovieTexture;
var canLoad:boolean=false;
function Start(){
movieTexture.Play();
LoadLevelAsynchronously();
camera.main.audio.Play();
Debug.Log("level was loaded");
}
function OnGUI () {
GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height),movieTexture,ScaleMode.StretchToFill);
if(!movieTexture.isPlaying)
canLoad=true;
}

function LoadLevelAsynchronously(){
introVid=Application.LoadLevelAsync("Menulvl");
while(!introVid.isDone&&canLoad==false)
yield;


}

What am i doing wrong here?

I know this is a really old question but as I came across this when searching for something else I thought I’d answer.

It’s basically exactly what I asked here and the answer is that you can’t use LoadLevelAsync to choose when to switch levels. It will load the level in the background but then switch as soon as it is ready.

You could use AssetBundles to achieve something, as pointed out in the above link.