Two videos supposed to load and then play one problem

Hi,

I’m making my portfolio website. In my video section I would like to have the finished video playing when clicked, and when you click the “Before/After” button it should minimize the “After” video and then the “Before” video comes in. Makes any sence?
Those two videos should play simultaneously. For now the play unsynched. So it seems like it is loading one and plays it meanwhile the other one is loading and then plays that one aswell.

Is there any way to make them load and when they are both loaded they play?

Here’s the code:

largeImage is the “After” and largeImageBefore is the “Before”.

myVideoPlayer is the movieclip with the two player inside, named myFLV and myFLVBefore.



info_butt.useHandCursor=false;
info_mc.hide_butt.useHandCursor=false;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.media.SoundMixer;
//LISTEN FOR THE CLICK OF THE BUTTONS
myVideoPlayer.bar.skinAutoHide = true;

//SOUND
var clickSound:Sound=new Sound(new URLRequest("sound/click.mp3"));


//XML
var titleArray:Array = new Array();
var descriptionArray:Array = new Array();
var clientArray:Array = new Array();
var largeImageArray:Array = new Array();
var largeImageBeforeArray:Array = new Array();
var thumbnailImageArray:Array = new Array();

var imageNum:Number=0;
var totalImages:Number;
//Load in XML
var XMLURLLoader:URLLoader = new URLLoader();
XMLURLLoader.load(new URLRequest("video/video.xml"));
XMLURLLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(event:Event):void {
	var theXMLData:XML=new XML(XMLURLLoader.data);
	totalImages=theXMLData.title.length();
	for (var i:Number = 0; i < totalImages; i++) {
		titleArray.push(theXMLData.title*);
		descriptionArray.push(theXMLData.description*);
		clientArray.push(theXMLData.client*);
		largeImageArray.push(theXMLData.largeImage*);
		largeImageBeforeArray.push(theXMLData.largeImageBefore*);
		thumbnailImageArray.push(theXMLData.thumbImage*);
	}
	loadThumbnail();
}

myScrollPane.source=allThumbnails;
//LOAD THE THUMBNAILS

function loadThumbnail():void {
	trace(imageNum);
	var thumbLoader:Loader = new Loader();
	thumbLoader.load(new URLRequest(thumbnailImageArray[imageNum]));
	thumbLoader.x=180*imageNum;
	//Stores the appropriate info for the thumbnail
	var thisLargeImage:String=largeImageArray[imageNum];
	var thisLargeImageBefore:String=largeImageBeforeArray[imageNum];
	var thisTitle:String=titleArray[imageNum];
	var thisDescription:String=descriptionArray[imageNum];
	var thisClient:String=clientArray[imageNum];
	thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
	function thumbLoaded(event:Event):void {
		//add the thumbnail to the allThumbnails instance
		allThumbnails.addChild(thumbLoader);
		allThumbnails.buttonMode=true;
		myScrollPane.update();
		thumbLoader.addEventListener(MouseEvent.CLICK, loadMainImage1);
		function loadMainImage1(event:MouseEvent):void {
			clickSound.play();
			myVideoPlayer.myFLV.source =thisLargeImage;
			myVideoPlayer.myFLV.play();
			myVideoPlayer.myFLVBefore.source =thisLargeImageBefore;
			myVideoPlayer.myFLVBefore.play();

			

			beforeAfter(5,-16,576,321,-819,-16);
			info_mc.selectedTitle.text=thisTitle;
			info_mc.selectedDesc.htmlText=thisDescription;
			info_mc.selectedClient.text=thisClient;
			//Add Preloader to images..
			myVideoPlayer.myFLV.addEventListener(ProgressEvent.PROGRESS, largeImagePreloader);
			function largeImagePreloader(event:ProgressEvent):void {
				var percent:Number = Math.round((event.bytesLoaded*100)/event.bytesTotal);
				percent_txt.text = percent +"%";
				
			}
			
		}
	}
	//add to imageNum (1);
	imageNum++;
	if (imageNum<totalImages) {
		loadThumbnail();
	}
}

	



function moveInfo(theXPosition:Number, theYPosition:Number, theRotation:Number,theSection:String):void {
	trace("X: "+theXPosition);
	trace("Y: "+theYPosition);
	trace("Rotation: "+theRotation);

	
	
	var myxTween:Tween=new Tween(info_mc,"x",Regular.easeOut,info_mc.x,theXPosition,1,true);
	var myyTween:Tween=new Tween(info_mc,"y",Regular.easeOut,info_mc.y,theYPosition,1,true);
	var myrotateTween:Tween=new Tween(info_mc,"rotation",Regular.easeOut,info_mc.rotation,theRotation,1,true);

	myrotateTween.addEventListener(TweenEvent.MOTION_FINISH, donePlaying);
	function donePlaying(e:TweenEvent):void {
		
	}
}



function beforeAfter(theXPosition:Number, theYPosition:Number, theWidth:Number, theHeight:Number,theAX:Number,theAY:Number):void {
	trace("X: "+theXPosition);
	trace("Y: "+theYPosition);
	trace("width: "+theWidth);
	trace("height: "+theHeight);
	trace("x: "+theAX);
	trace("y: "+theAY);
	var myxTween:Tween=new Tween(myVideoPlayer.myFLV,"x",Regular.easeOut,myVideoPlayer.myFLV.x,theXPosition,1,true);
	var myyTween:Tween=new Tween(myVideoPlayer.myFLV,"y",Regular.easeOut,myVideoPlayer.myFLV.y,theYPosition,1,true);
	var myWTween:Tween=new Tween(myVideoPlayer.myFLV,"width",Regular.easeOut,myVideoPlayer.myFLV.width,theWidth,1,true);
	var myHTween:Tween=new Tween(myVideoPlayer.myFLV,"height",Regular.easeOut,myVideoPlayer.myFLV.height,theHeight,1,true);	
	var myAXTween:Tween=new Tween(myVideoPlayer.myFLVBefore,"x",Regular.easeOut,myVideoPlayer.myFLVBefore.x,theAX,1,true);
	var myAYTween:Tween=new Tween(myVideoPlayer.myFLVBefore,"y",Regular.easeOut,myVideoPlayer.myFLVBefore.y,theAY,1,true);	

	myHTween.addEventListener(TweenEvent.MOTION_FINISH, donePlaying);
	function donePlaying(e:TweenEvent):void {
		
	}
}



info_butt.addEventListener(MouseEvent.CLICK, infoClick);
function infoClick(e:MouseEvent):void {
	trace("infoClick");

	moveInfo(756.95,316.55,0, null);
	
}

myVideoPlayer.beforeafter_butt.addEventListener(MouseEvent.CLICK, beforeafterClick);
function beforeafterClick(e:MouseEvent):void {
	trace("beforeafterClick");

	beforeAfter(280,-16,388,213.60,-175,-16);


}

info_mc.hide_butt.addEventListener(MouseEvent.CLICK, hideClick);
function hideClick(e:MouseEvent):void {
	trace("hideClick");

	moveInfo(2180,316.55,0, null);
	
}