Jump to content
Search Community

Basic LoaderMax tutorial by Zync

chefkeifer test
Moderator Tag

Recommended Posts

I have been following Zync's tutorial and have done everything he has done. As far as i know.

 

I keep getting this error.

 

TypeError: Error #1010: A term is undefined and has no properties.
at main/xmlLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.greensock.loading.core::LoaderCore/_completeHandler()
at com.greensock.loading::XMLLoader/_completeHandler()
at com.greensock.loading::XMLLoader/_receiveDataHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

 

here is my code.

package  
{
import com.greensock.events.*;
import com.greensock.loading.*;
import com.greensock.*;
import flash.display.Sprite;
import flash.display.MovieClip;
import com.greensock.loading.XMLLoader;
import com.greensock.events.LoaderEvent;
import com.greensock.loading.LoaderMax;
import com.greensock.loading.ImageLoader;
import com.greensock.loading.data.ImageLoaderVars;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import com.greensock.loading.display.ContentDisplay;


public class main extends Sprite 
{
	public var thumbHolder:MovieClip;
	public var mainHolder:MovieClip;

	public var titleTxt:TextField;
	public var descTxt:TextField;

	private var xImgList:XMLList;


	public function main() 
	{
		//load in  our xml
		var xPhotography:XMLLoader = new XMLLoader("xml/buggies.xml");
		xPhotography.addEventListener(LoaderEvent.COMPLETE, xmlLoaded);
		xPhotography.load();
	}

	private function xmlLoaded(e:LoaderEvent):void
	{
		var xData:XML = e.target.content;
		xImgList = new XMLList(xData.img);

		//Setup a loadermax object
		var thumbLoader:LoaderMax = new LoaderMax({name:"thumbLoader"});
		thumbLoader.addEventListener(LoaderEvent.COMPLETE, thumbsLoaded);
		//setup variables for our imageLoader Vars
		var nImgWidth:Number = 150;
		var nImgHeight:Number = 100;
		var nMaxCols:Number = 2;
		for (var i:int = 0; 1 < xImgList.length(); i++)
		{
			var iLoad:ImageLoader = new ImageLoader("images/buggies/" + xImgList[i].@url, new ImageLoaderVars()
			.name(xImgList[i].@name)
			.width(nImgWidth)
			.height(nImgHeight)
			.smoothing(true)
			.container(thumbHolder)
			.x((i % nMaxCols) * nImgWidth)
			.y(int(i / nMaxCols) * nImgHeight)
			.scaleMode("proportionalOutside")
			.crop(true)
			.prop("index", i)
			.prop("url", xImgList[i].@url)
			.prop("title", xImgList[i].@title)
			.prop("desc", xImgList[i].@desc)
			.alpha(0)
			)
			thumbLoader.append(iLoad);			
		}

		thumbLoader.load();
	}
	private function thumbsLoaded(e:LoaderEvent):void
	{
		//setup click events for our thumbnails
		for (var i:int = 0; 1 < xImgList.length(); i++)
		{
			var cdImg:ContentDisplay = LoaderMax.getContent("p" + (i+1));
			cdImg.buttonMode = true;
			cdImg.addEventListener(MouseEvent.CLICK, thumbClick);
			TweenMax.to(cdImg, 1, {autoAlpha:1, delay:(i*0.2)} );
		}
	}

	private function thumbClick(e:MouseEvent):void
	{
		var vars:Object = ImageLoader(e.currentTarget.loader).vars;
		trace(vars.title);
		checkOldImage(vars.index)
	}

	private function checkOldImage(index:Number):void
	{
		//check if theres alreayd an image loaded
		if(mainHolder.numChildren > 0)
		{
			var oldClip:Sprite = Sprite(mainHolder.getChildAt(0));
			TweenMax.to(oldClip, 0.5, {autoAlpha:0, onComplete:function(){ mainHolder.removeChildAt(0); loadImage(index) } });
		}else
		{
			loadImage(index);
		}

	}


	private function loadImage(index:Number):void
	{
		//Get filename
		var file:String = xImgList[index].@url;

		//change text display
		titleTxt.text = "Title:" + xImgList[index].@title;
		descTxt.text = "Description:" + xImgList[index].@desc;
		//setup our main image loader
		var mainLoad:ImageLoader = new ImageLoader("images/buggies/" + file, new ImageLoaderVars()
		.width(500)
		.height(500)
		.scaleMode("proportionalInside")
		.container(mainHolder)
		.smoothing(true)
		)
		//setup event listeners
		mainLoad.addEventListener(LoaderEvent.COMPLETE, imageLoaded);

		mainLoad.load();
	}

	private function imageLoaded(e:LoaderEvent):void
	{
		var imgClip:ContentDisplay = LoaderMax.getContent(e.currentTarget.name);
		TweenMax.to(imgClip, 0, {colorTransform: {exposure:2}} );
		TweenMax.to(imgClip, 1.5, {colorTransform: {exposure:1}, autoAlpha:1} ); 
	}


}

}

Link to comment
Share on other sites

zync will be better suited to help you.

 

by just scanning the code the only thing i wonder is if thumbHolder is the unknown element.

 

up top it appears that you declare thumbHolder to be a movieclip but I don't see that it points to anything.

 

just a guess.

 

I would suggest commenting out chunks like your loop and seeing if the error goes away and then try to narrow it down.

 

 

 

-c

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