...

View Full Version : Resolved "Previous" button throws errors



marilynn.fowler
06-08-2009, 08:00 AM
I've created a slideshow with "previous" and "next" buttons. The "next" button works fine. I trace it's output and it advances as normal. The "previous" button outputs -1 and gives me the following error:

TypeError: Error #1010: A term is undefined and has no properties.
at _slideshow_fla::MainTimeline/packagedF()
at _slideshow_fla::MainTimeline/checkerF()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

I think the error is in the "checkerF" function, but I don't know how to correct it. Any help would be appreciated.


var xmlRequest:URLRequest = new URLRequest("_data.xml");
var xmlLoader:URLLoader = new URLLoader(xmlRequest);
var imgData:XML;
var imgLoader:Loader;
var rawImg:String;

/*
var rawW:String;
var rawH:String;
*/

var imgNum:Number = 0;
var checkSec:Timer = new Timer(100);
var numberOfChildren:Number;

xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedF);
next_btn.addEventListener(MouseEvent.CLICK, nextImgF);
prev_btn.addEventListener(MouseEvent.CLICK, prevImgF);

function xmlLoadedF(event:Event):void {
checkSec.start();
checkSec.addEventListener(TimerEvent.TIMER, checkerF);
imgData = new XML(event.target.data);
}

function packagedF():void{
checkSec.removeEventListener(TimerEvent.TIMER, checkerF);
rawImg = imgData.image[imgNum].imgURL;
numberOfChildren = imgData.*.length();

/* gets width and height from xml sheet
rawW = imgData.image[imgNum].imgW;
rawH = imgData.image[imgNum].imgH;
*/

imgLoader = new Loader;
imgLoader.load(new URLRequest(rawImg));
master_mc.addChild(imgLoader);

/* centers image. note, turn off bandwidth profiler if you get error. Flash bug
imgLoader.x = (stage.stageWidth - Number(rawW)) / 2;
imgLoader.y = (stage.stageHeight - Number(rawH)) / 2;
*/
}

function checkerF(event:TimerEvent):void {
if (imgNum == 0) {
packagedF();
} else if (imgNum < 0) {
imgNum = numberOfChildren;
packagedF();
} else if (imgNum < numberOfChildren) {
imgLoader.unload();
packagedF();
} else {
imgLoader.unload();
imgNum = 0;
packagedF();
}
}

function nextImgF(event:MouseEvent):void {
checkSec.addEventListener(TimerEvent.TIMER, checkerF);
imgNum++;
trace(imgNum);
}
function prevImgF(event:MouseEvent):void {
checkSec.addEventListener(TimerEvent.TIMER, checkerF);
imgNum--;
trace(imgNum);

}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum