Jump to content
Search Community

autoDispose makes SWF not responding

penny test
Moderator Tag

Recommended Posts

Hi,

 

I'm creating a website header, with images and SWFs loaded into it. The code below:

 

package
{
import com.greensock.events.LoaderEvent;
import com.greensock.loading.ImageLoader;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.SWFLoader;
import com.greensock.loading.XMLLoader;
import com.greensock.loading.core.DisplayObjectLoader;

import flash.display.Sprite;
import flash.display.StageScaleMode;

[sWF(width="960", height="435", frameRate="30", backgroundColor="#FFFFFF")]

public class Header extends Sprite
{
	private var types:Object = {png: ImageLoader, jpg: ImageLoader, swf: SWFLoader};

	private var queue:LoaderMax = new LoaderMax({onComplete: onQueueComplete});

	private var items:XMLList;

	public function Header()
	{
		stage.scaleMode = StageScaleMode.NO_SCALE;
		stage.showDefaultContextMenu = false;

		LoaderMax.activate([imageLoader, SWFLoader]);

		var loader:XMLLoader;
		var params:Object = {onOpen: onOpen, onProgress: onProgress, onComplete: onComplete, noCache: true, autoDispose: true};
		CONFIG::DEBUG
		{
			loader = new XMLLoader("data.xml", params);
		}
		CONFIG::RELEASE
		{
			loader = new XMLLoader(this.root.loaderInfo.parameters.dataURL, params);
		}
		loader.load();
	}

	private function onOpen(e:LoaderEvent):void
	{
		trace("onOpen");
	}

	private function onProgress(e:LoaderEvent):void
	{
		trace("onProgress");
	}

	private function onComplete(e:LoaderEvent):void
	{
		var data:XML = e.target.content;

		items = data.item;
		var i:int = items.length(), item:XML;
		var url:String, type:String;
		var params:Object = {onComplete: onItemComplete, autoDispose: true};
		var loader:DisplayObjectLoader;
		while (--i > -1)
		{
			item = items[i];
			url = item.content[0].toString();
			type = url.toLowerCase().split("?")[0];
			type = type.substr(type.lastIndexOf(".") + 1);
			loader = new types[type](url, params);
			queue.append(loader);
		}
		queue.load();
	}

	private function onItemComplete(e:LoaderEvent):void {}

	private function onQueueComplete(e:LoaderEvent):void {}
}
}

 

Setting autoDispose to true for each loader makes the SWF freeze. Any tips, why is that happening and what to do with it?

Link to comment
Share on other sites

I can't test your code as I don't have your assets, know how your xml is formatted or know where your assets live. These are all areas where multiple variables exist to cause errors.

 

I would suggest:

 

adding traces in your loop. are the queue loaders being created properly?

if your swf is not responding, perhaps the loop is never completing as its termination conditions are never being met.

usually this will cause a run-time error or script timeout error in the flash ide. "not responding" usually implies some sort of near-crash or processor/memory overload which 99% of the time are caused by a malformed loop.

 

try adding onComplete, onFail, onError, onSecurityError callback functions with the appropriate traces to each inividual item loader to see if a particular item is causing problems.

 

 

That's the best I can guess by just looking at the code.

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...