Jump to content
Search Community

VideoLoader: all video start at same time

ilanb test
Moderator Tag

Recommended Posts

Hello,

 

When loading videos is completed, all videos play at same time. How to change this ?

 

I would like play just the 2 addChild videos:

 

LoaderMax.activate([VideoLoader]); 

		var urls:Array = ["3_DialS1_P1.flv", "3_DialS1_V1.flv", "3_DialS1_P2.flv", "3_DialS1_V2.flv", "3_DialS1_P3.flv", "3_DialS1_V3.flv", "3_DialS1_P4.flv", "3_DialS1_V4.flv", "3_DialS1_P5.flv", "3_DialS1_V5.flv", "3_DialS1_P6.flv", "3_DialS1_V6.flv", "3_DialS1_P7.flv", "3_DialS1_V7.flv", "Left.flv", "Right.flv", "Sad.flv", "Wait1.flv", "Wait2.flv", "Wait3.flv", "Wait4.flv", "WaitV1.flv"];
		var queue:LoaderMax = LoaderMax.parse(urls, 
			{maxConnections:3,
				onProgress:_progressHandler, 
				onComplete:_queueCompleteHandler, 
				onChildComplete:_childCompleteHandler});
		queue.prependURLs("files/assets/flv/critical/");
		queue.load();

	}

	private function _progressHandler(event:LoaderEvent):void {
		this.progress_mc.progressBar_mc.scaleX = event.target.progress;

		progress_mc.x = int ((Main.instance.getStage().stageWidth - width)/2);
		progress_mc.y = int ((Main.instance.getStage().stageHeight - height)/2);

	}

	private function _queueCompleteHandler(event:LoaderEvent):void {

		var videoP:VideoLoader = LoaderMax.getLoader("files/assets/flv/critical/3_DialS1_P1.flv");
		addChild(videoP.content);
		videoP.content.x = 0;
		videoP.content.y = 0;

		var videoV:VideoLoader = LoaderMax.getLoader("files/assets/flv/critical/3_DialS1_V1.flv");
		addChild(videoV.content);
		videoV.content.x = 0;
		videoV.content.y = 0;


	}

 

Last question, how I can access to other videos loaded ?

 

Thanks

Link to comment
Share on other sites

When loading videos is completed, all videos play at same time. How to change this ?

 

By default, autoPlay is true. You can set all of them to false by using the 3rd parameter of LoaderMax.parse() (and make sure you have the latest version of LoaderMax):

 

var queue:LoaderMax = LoaderMax.parse(urls,
           {maxConnections:3,
              onProgress:_progressHandler,
              onComplete:_queueCompleteHandler,
              onChildComplete:_childCompleteHandler},
           {autoPlay:false});

 

Then simply call playVideo() on the VideoLoader(s) to start playing the video(s).

 

Last question, how I can access to other videos loaded ?

 

You have several options:

 

1) Use LoaderMax.getLoader() or LoaderMax.getContent() to search by the URL or name. It looks like you already know how to do that.

 

2) You can get an array of all the children of the LoaderMax using its getChildren() method. Then you can loop through them or access them directly.

 

var loaders:Array = queue.getChildren();
var myThirdVideoLoader:VideoLoader = loaders[2];
myThirdVideoLoader.playVideo();

Link to comment
Share on other sites

Thanks Jack, very useFull !!!

 

just trying to play with array:

 

var loaders:Array = queue.getChildren();
		var videoP:VideoLoader = loaders[2,3];
		addChild(videoP.content);
		videoP.content.x = 0;
		videoP.content.y = 0;
		videoP.playVideo();

 

 

 

but error message:

 

child loaded: VideoLoader 'loader2' (files/assets/flv/critical/3_DialS1_P1.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader3' (files/assets/flv/critical/3_DialS1_V1.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader4' (files/assets/flv/critical/3_DialS1_P2.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader5' (files/assets/flv/critical/3_DialS1_V2.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader7' (files/assets/flv/critical/3_DialS1_V3.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader6' (files/assets/flv/critical/3_DialS1_P3.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader8' (files/assets/flv/critical/3_DialS1_P4.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader9' (files/assets/flv/critical/3_DialS1_V4.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader10' (files/assets/flv/critical/3_DialS1_P5.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader11' (files/assets/flv/critical/3_DialS1_V5.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader12' (files/assets/flv/critical/3_DialS1_P6.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader13' (files/assets/flv/critical/3_DialS1_V6.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader14' (files/assets/flv/critical/3_DialS1_P7.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader15' (files/assets/flv/critical/3_DialS1_V7.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader16' (files/assets/flv/critical/Left.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader17' (files/assets/flv/critical/Right.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader18' (files/assets/flv/critical/Sad.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader19' (files/assets/flv/critical/Wait1.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader20' (files/assets/flv/critical/Wait2.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader21' (files/assets/flv/critical/Wait3.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader22' (files/assets/flv/critical/Wait4.flv) inside queue: LoaderMax 'loader1'
child loaded: VideoLoader 'loader23' (files/assets/flv/critical/WaitV1.flv) inside queue: LoaderMax 'loader1'
ReferenceError: Error #1069: La propriété 3 est introuvable sur Number et il n'existe pas de valeur par défaut.
at view::LoaderBoxView/_queueCompleteHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.greensock.loading.core::LoaderCore/_completeHandler()
at com.greensock.loading::LoaderMax/_loadNext()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.greensock.loading.core::LoaderCore/_completeHandler()
at com.greensock.loading::VideoLoader/_enterFrameHandler()

 

if I use just one number in array work fine.

 

Thanks

Link to comment
Share on other sites

You cannot access multiple indexes in an array like that.

 

BAD: loaders[2,3]

GOOD: loaders[2]

 

(that has nothing to do with LoaderMax - it's how all arrays work in ActionScript and pretty much any other language I've ever seen)

 

If you want to add both loaders' content to the stage, you could do:

 

var loaders:Array = queue.getChildren();
var videoP:VideoLoader = loader[2];
addChild(videoP.content);
videoP.playVideo();
videoP = loader[3]; //reuse the videoP variable
addChild(videoP.content);
videoP.playVideo();

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...