Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    San Francisco
    Posts
    455
    Thanks
    19
    Thanked 15 Times in 15 Posts

    "Previous" button throws errors

    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.

    Code:
    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);
    
    }
    Last edited by marilynn.fowler; 06-09-2009 at 02:59 AM.
    Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •