Trying to get th eback and next buttons working in my main class

hi. i’ve been trying to hack away at getting the back and next buttons to work on this, and essentially getting nowhere. here’s what i need to do:

when a user first comes to the page, the first this they see is the currentevent, so it loads the currevent.

i need to set up a conditional, such that #1, the buttons will increment or decrement from whatever the value is of currentevent.

i also need to set the increment/decrement so that if the user clicks on a thumb, it goes to the next id number from the one they clicked on, in order.

in my xml, i have 2 nodes: one sets currentevent to true, the other gives each event (named activity in the nodes) an id number.

i’m building the layout of the thumbs in main, and loading the thumbs (from Thumbnail class) and calendar events (from CalendarEvent class).

so, pick it apart. tell me what i really need to do. i tried to set up functions for the buttons, and they’re loading on the stage, but i’m throwing an error when i click on them.

thanks.

package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.display.Loader;
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;
    import flash.net.URLLoader;

    public class Main extends Sprite {

        private var imagesXML:XML;
        private var counter:uint;
        private var thumbs:Array = new Array();
        private var thumb_mc:Sprite;
        private var contents_mc:Sprite;
        private var prevBtn:PrevBTN;
        private var nextBtn:NextBTN;
        private var currevent:Thumbnail;
        private var currThumb:Number;
        private var activityid:Thumbnail;
        private var activity:Thumbnail;
        private var stroke:Shape;
        private var eventNum:Number;
        //private var eventID:XmlList;
        private var totalEvents:Number;
        private var xmlList:XMLList;
        private var eventDetail:CalendarEvent = new CalendarEvent();
        private var onHoverLeft:Thumbnail;


        public function Main() {

            var url:URLRequest=new URLRequest("data.xml");
            var urlLoader:URLLoader = new URLLoader();
            urlLoader.addEventListener(Event.COMPLETE, urlLoadCompleteHandler);
            urlLoader.load(url);

        }

        public function urlLoadCompleteHandler(e:Event):void {
            imagesXML=new XML(e.target.data);
            displayAllImages(imagesXML);

            xmlList=imagesXML.children();
            var totalEvents:Number=xmlList.length();
            
            //var currThumb:XMLList = eventid;
            //var eventNum:Number=0;

            //trace(totalEvents + " total events");

        }

        public function displayAllImages(xml:XML):void {

            var eventid:XMLList=xml.activity.eventid;
            var currentevent:XMLList=xml.activity.currentevent;
            var date:XMLList=xml.activity.date;
            var title:XMLList=xml.activity.title;
            var image:XMLList=xml.activity.image;
            var thumb:XMLList=xml.activity.thumb;
            var credit:XMLList=xml.activity.credit;
            var caption:XMLList=xml.activity.caption;
            var blurb:XMLList=xml.activity.blurb;
            var linktitle:XMLList=xml.activity.relatedtitle;        
            var link:XMLList=xml.activity.relatedlink;


            var totalEvents:Number=xml.length() - 1;
            var eventNum:Number=0;
            var currThumb:XMLList = eventid;
            
            var thumbs:Array = new Array();
                
                var nextBtn:MovieClip = new NextBTN();
                nextBtn.x = 513;
                nextBtn.y = 190;
                //nextBtn = eventid.length();
                nextBtn.buttonMode=true;
                nextBtn.mouseChildren=false;
                nextBtn.addEventListener(MouseEvent.CLICK, onNextSlide, false, 0, true);
                addChild(nextBtn);
                
                var prevBtn:MovieClip = new PrevBTN();                
                prevBtn.x = 370;
                prevBtn.y = 190;
                //prevBtn = eventid.length();
                prevBtn.buttonMode=true;
                prevBtn.mouseChildren=false;
                prevBtn.addEventListener(MouseEvent.CLICK, onPrevSlide, false, 0, true);
                addChild(prevBtn);

            eventDetail.x=2;
            eventDetail.y=240;

            addChild(eventDetail);


            for (var j:uint = 0; j<thumb.length(); j++) {

                displayThumb(thumb[j], title[j], date[j], eventid[j], currentevent[j], image[j], blurb[j], credit[j], caption[j], linktitle[j], link[j]);

            }

            displayEvent(currevent);

        }

        public function displayEvent(activity:Thumbnail):void {

            eventDetail.loadEvent(activity);


        }


        public function displayThumb(thumb:String, title:String, date:String, activityid:String, currentevent:String, image:String, blurb:String, credit:String, caption:String, relatedtitle:String, relatedlink:String):void {
            
            var stroke:Shape = new Shape();
            stroke.graphics.lineStyle(5, 0xFFCC66, 1, true, "none", null, JointStyle.MITER, 3);
            stroke.graphics.drawRect(6, 2, 71, 71);

            var thumb_mc:Thumbnail=new Thumbnail(thumb,title,date);

            var currThumb = activityid;

            if (currentevent=="true") {

                currevent=thumb_mc;

                thumb_mc.addChild(stroke);
                stroke.visible=true;
                
            }

            thumb_mc.x=counter*86;
            thumb_mc.y=10;
            
            thumb_mc.name = activityid;

            thumbs.push(activityid);
            thumb_mc.addEventListener(MouseEvent.MOUSE_UP, clickOnThumb, false, 0, true);
            //thumb_mc.addEventListener(MouseEvent.MOUSE_OVER, changeThumbLayout, false, 0, true);

            if (thumb_mc.x >= stage.stageWidth-5) {

                thumb_mc.x=thumb_mc.x-thumb_mc.width-346;
                thumb_mc.y=thumb_mc.height+10;
                //thumb_mc.boxX = -175;

            }
            
/*            if (thumb_mc.width >= stage.stageWidth - 5) {
                
                this.onHoverLeft();
                
            }*/

            addChild(thumb_mc);

            thumb_mc.activityid=activityid;
            thumb_mc.activitythumb=thumb;
            thumb_mc.activitytitle=title;
            thumb_mc.activitydate=date;
            thumb_mc.activityimage=image;
            thumb_mc.activitycredit=credit;
            thumb_mc.activitycaption=caption;
            thumb_mc.activityblurb=blurb;
            thumb_mc.activitylinktitle=relatedtitle;
            thumb_mc.activitylink=relatedlink;

            counter++;
        }
    
    
    public function onNextSlide(e:MouseEvent):void {
        
        //currThumb = e.target.activityid;
        
        if (currThumb >= 0) { 
        
        displayEvent(e.target as Thumbnail);
        
        currThumb++;
        
        }
    }

    public function onPrevSlide(e:MouseEvent):void {
        
        //currThumb = e.target.activityid;
    
        if (currThumb <= 0) {
            
        displayEvent(e.target as Thumbnail);
        
        currThumb--;
        
        }
    }
    
    public function clickOnThumb(e:MouseEvent):void {
        
        displayEvent(e.target as Thumbnail);
        
            currThumb = e.target.activityid;
            
            //eventNum = currThumb;
            
            trace(currThumb);
                
        }

    }
}