Jump to content


Contentdisplay and dispose() error

Moderator Tag

Recommended Posts



When the first two video are completed I try to delete before playing 2 other videos but if I use dipose, unload... (VIDEO_COMPLETE) I have an 1009 error


If I try to use removeChild methode it's same.


public function loadContentCritical():void

		//activate the loaders

		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"];
		queue = LoaderMax.parse(urls, 
				onChildComplete:_childCompleteHandler}, {autoPlay:false});


	private function _queueCompleteHandler(event:LoaderEvent):void {

		var loaders:Array = queue.getChildren();
		var videos:VideoLoader = loaders[1];

		videos = loaders[17]; //reuse the videoP variable

		videos.addEventListener(VideoLoader.VIDEO_COMPLETE, onVideoComplete, false, 0, true);


	private function onVideoComplete(_event:Event):void {


		var loaders:Array = queue.getChildren();
		var videos:VideoLoader = loaders[0];

		videos = loaders[21];



How I can remove videos and play next ?



Link to comment
Share on other sites

There are several problems with your code:


1) You create a local "videos" variable inside your _queueCompleteHandler() method and then you try to reference it inside another function, onVideoComplete(). You can't do that. Local variables only exist within the function where they are defined. You could, of course, define that variable as a class-level variable instead if you need to access it other places.


2) If you dispose() one of the VideoLoaders in your LoaderMax, keep in mind that it will be...disposed...gone...vamoose...removed. Your code looks like it relies on loaders being at specific index values of the LoaderMax but that's a dangerous way to engineer things. Imagine you've got 20 loaders and you load the first and second ones (index 0 and 1). Then you dispose - since those get deleted from the LoaderMax queue, the index values shift, so what USED to be index 2 and 3 now become index 0 and 1. See the problem? It isn't a "wrong" way to code your stuff, but you just need to be careful about the whole index thing. It might be better to reference your loaders based on their name or url using LoaderMax.getLoader("myLoaderNameOrURL");

Link to comment
Share on other sites

Thanks Jack,


It's much clearer now !!


I have created a generic videoloader class and use


to play video and

public function videoEnd():void 

		return _currentVideo.unload();



to unload


Work like a charm :-)


I have found good tuts to help me a lot : http://active.tutsplus.com/tutorials/actionscript/smart-as3-video-loading-with-greensock-loadermax-free-active-premium/ :mrgreen:

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.