SWF Player with Slider Component timeline control

I’ve created a SWF Player that loads external swfs from an XML playlist. I am working on adding playback controls. So far, I’ve been able to achieve a working slider component that scrubs the external swf’s timeline. However, it is faulty and the slider thumb doesn’t follow move with the timeline of the swf-it just remains still. What I mean by faulty is that sometimes the slider scrubs the swf timeline and sometimes it fails with this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at swfPlayerMain/sliderDrag()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::Slider/doDrag()

I think it may have something to do with the order of my code or I need to add an enter frame function. If that’s true, where does it go?

Thanks for checking it out!

The following code is my Document Class (AS3) code:


package 
{ 
    import flash.events.EventDispatcher; 
    import flash.events.Event; 
    import flash.events.MouseEvent; 
    import flash.display.Sprite; 
    import flash.display.MovieClip; 
    import fl.controls.*; 
    import flash.display.*; 
    import flash.xml.*;  
    import flash.events.*; 
    import flash.display.Loader; 
    import flash.net.URLLoader; 
    import flash.net.URLRequest; 
    import flash.text.*;     
    import flash.utils.getDefinitionByName; 
    import flash.utils.describeType; 
    import flash.geom.*; 
     
    import fl.events.SliderEvent; 
    import fl.controls.Slider; 
    import fl.controls.Label;     
     
     
    public class swfPlayerMain extends MovieClip 
    { 
        public var swf_x:Number; 
        public var swf_y:Number; 
        //my_presentations = toolsXMLList 
        public var toolsXMLList:XMLList; 
        //my_total = total_swfs 
        public var total_swfs:Number; 
        //presentation_loader = swf_loader         
        public var swf_loader:Loader = new Loader(); 

        //myXML = swfXML 
        public var swfXML:XML; 
        //myXMLLoader = toolsXMLLoader 
        public var toolsXMLLoader:URLLoader = new URLLoader(); 
                  
        public var slider:Slider = new Slider; 
        public var sliderLabel:Label; 
        public var timeline:MovieClip; 
        public var swf_loader_container:MovieClip; 
         

        //add ZOOM and PAN buttons and features 
        trace("swfPlayerMain_01"); 

         
        public function setupButtons():void 
        { 

            var rotate_btn:rotateBTN = new rotateBTN(); 
            rotate_btn.x = 35; 
            rotate_btn.y = 168; 
            addChild(rotate_btn); 
            rotate_btn.addEventListener(MouseEvent.CLICK, rotateSWF); 
                         
            var explode_btn:explodeBTN = new explodeBTN(); 
            explode_btn.x = 160; 
            explode_btn.y = 168; 
            addChild(explode_btn); 
            explode_btn.addEventListener(MouseEvent.CLICK, explodeSWF); 
             
            var action_btn:actionBTN = new actionBTN(); 
            action_btn.x = 318; 
            action_btn.y = 168; 
            addChild(action_btn); 
            action_btn.addEventListener(MouseEvent.CLICK, actionSWF); 
             
            var loop360_btn:Loop_360 = new Loop_360(); 
            loop360_btn.x = 24; 
            loop360_btn.y = 168; 
            addChild(loop360_btn); 
            loop360_btn.addEventListener(MouseEvent.CLICK, loopAction_360); 
             
             
            trace("swfPlayerMain_03"); 


        } 
         
         
        public function setUpSlider():void 
        { 
            slider.x = 45; 
            slider.y = 150; 
            slider.width = 380; 
            slider.height = 8; 
            slider.maximum = 100; 
            slider.liveDragging = true;                     
            addChild(slider); 

            trace("swfPlayerMain_04"); 
             
        } 
         
        public function setUpLabel():void 
        { 
            sliderLabel = new Label; 
            sliderLabel.x = 40; 
            sliderLabel.y = 180; 
            addChild(sliderLabel); 
             
            trace("swfPlayerMain_05"); 
             
        } 

        public function configureListeners():void  
        { 
            slider.addEventListener(SliderEvent.CHANGE, sliderChanged); 
            slider.addEventListener(SliderEvent.THUMB_DRAG, sliderDrag); 
            slider.addEventListener(SliderEvent.THUMB_PRESS, sliderPress);             
            slider.addEventListener(SliderEvent.THUMB_RELEASE, sliderRelease); 
             
            trace("swfPlayerMain_06"); 
             
        }         
         
        public function processXML (event:Event):void  
        { 
            swfXML = new XML(toolsXMLLoader.data); 
             
            swf_x = swfXML.@SWF_X; 
            swf_y = swfXML.@SWF_Y; 
            toolsXMLList = swfXML.SWFS; 
            total_swfs = toolsXMLList.length(); 
             
            trace("swfPlayerMain_08");         
            makeLoader (); 
            trace("swfPlayerMain_10"); 

        } 
         
        public function makeLoader ():void  
        { 
            swf_loader_container = new MovieClip(); 
            addChild(swf_loader_container); 

            //The loaded display object (swf/jpg/png/gif) is added as a child  
            //of the Loader object 
            swf_loader.x = swf_x; 
            swf_loader.y = swf_y;                 
            swf_loader_container.addChild(swf_loader); 


            trace("swfPlayerMain_09"); 
            //swf_loader.load(new URLRequest (toolsXMLList[0].@ROTATE_URL)); 
        } 
         
     
        public function rotateSWF(event:MouseEvent):void 
        { 
            //play loaded swf (target?) 
            trace("rotateSWF Clicked"); 
             
            for (var i:Number = 0; i < total_swfs; i++)  
            { 
                //XML URL 
                var rotateURL = toolsXMLList*.@ROTATE_URL; 
                swf_loader.load(new URLRequest(rotateURL)); 
                swf_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swf_loaded); 


            } 
                 
        } 

        public function swf_loaded(event:Event):void 
        { 
            timeline = event.currentTarget.content; 
        } 
//-----SLIDER START---------------- 



        public function sliderDrag(e:SliderEvent):void  
        { 
            trace("Slider dragging: " + e.target.value); 
            sliderLabel.text = "Slider dragging: " + e.target.value;   
            timeline.gotoAndStop(e.target.value); 
        } 

        public function sliderPress(e:SliderEvent):void  
        { 
            sliderLabel.text = "Slider pressed";     
        } 

        public function sliderRelease(e:SliderEvent):void  
        { 
            sliderLabel.text = "Slider released";     
            timeline.gotoAndPlay(e.target.value); 

        } 

        public function sliderChanged(e:SliderEvent):void  
        { 
            sliderLabel.text = "Slider changed: " + e.target.value; 

        } 

//-----SLIDER END----------------------------- 
         
         
        public function explodeSWF(event:MouseEvent):void 
        { 
            trace("explodeSWF Clicked"); 
             
            for (var i:Number = 0; i < total_swfs; i++)  
            { 
                //XML URL 
                var explodeURL = toolsXMLList*.@EXPLODE_URL; 
                swf_loader.load(new URLRequest(explodeURL)); 
                //continue with movieclip.play or gotoandplay 
            } 
            trace("playing new swf"); 
        } 

        public function actionSWF(event:MouseEvent):void 
        { 
            //play loaded swf (target?) 
            trace("actionSWF Clicked"); 
             
            for (var i:Number = 0; i < total_swfs; i++)  
            { 
                //XML URL 
                var actionURL = toolsXMLList*.@ACTION_URL; 
                swf_loader.load(new URLRequest(actionURL)); 

            } 

             
        } 

        public function loopAction_360(event:MouseEvent):void 
        { 
            trace("loopAction_360 Clicked"); 
            event.currentTarget.content.gotoAndPlay("360view"); 
            //timeline.instMC.gotoAndPlay("360view"); 
        } 

        //CONSTRUCTOR FUNCTION 
        public function swfPlayerMain() 
        { 
            trace("swfPlayerMain_02");             
             
            toolsXMLLoader.load(new URLRequest("toolUIwindow_content.xml")); 
            toolsXMLLoader.addEventListener (Event.COMPLETE, processXML); 

            setupButtons(); 
            setUpSlider(); 
            setUpLabel(); 
            configureListeners();         
            trace("swfPlayerMain_07");             
             

        } 
    } 
}  

Thanks so much