Loader.close() problem

Hi everyone…
I was struggling with my image gallery…
And I bump to a new problem…
I want to end any previous data loading progresses… But I can’t manage to do this.
I tried lots of things (as you can see couple of them below), but it just can’t stop downloading of images. I click to first gallery button, it starts to download thumbs and the first picture. Then I click to second gallery button and it adds more download progress to the previous ones… (Every gallery has 4 thumb, this way every click adds 4 thumb and 1 picture. It’s download count grows 5+5+5 to infinite :slight_smile: )

This code is from my thumb class… Every thumb downloads it’s own little image…


        public function create(thumbPath: String):void 
        {
            try{
                    myLoader.close();
                    killMyLoader();
                    trace("myLoader's stream closed");
                }
            catch (err:Error) 
                { 
                    trace("myLoader has no stream to close");
                }
            finally
                {
                    trace("myLoader is getting ready");
                myLoader            = new Loader;
                dummyThumb            = new ThumbButton;
                myRequest            = new URLRequest(thumbPath);
                myLoader.load(myRequest);
                myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, Loading);
                myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, Loaded);
                addChild(myLoader);    
                progressBar            = new MyProgressBar();
                addChild(progressBar);
                progressBar.x = ((this.width - progressBar.width ) * .5 ) - progressBar.width; 
                progressBar.y = ((this.height- progressBar.height)  * .5 - progressBar.height);
            
                
                progressBar.alpha = 0;
                
                }
                
                
        }
        
        public function killMyLoader():void
        {
            trace("myLoader");
        
            try
            {    
                myLoader.close();
                myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, Loading);
                myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, Loaded);
                trace("myLoader connection is closed");
            }
            catch (e:Event) { trace("myLoader has no connection");
            }
            finally {            
                removeChild(myLoader);
            }

        }

And this from my thumbContainer class… It creates - controls the every thumb instance and adds them to the stage…

The code is where I create thumbs…


        public function create(thumbButtonArray: Array):void 
        {
            if (isThumbAdded) 
            {
                remove();
                
            }    
            thumbArray        = new Array;
                for (var i:int = 0; i < thumbButtonArray.length ; i++) 
                    {
                        thumbPath            = new String();
                        thumbPath            = thumbButtonArray*.@thumbpath;
                        
                        
                        thumbButton         = new ThumbButton();
                        thumbButton.x         = ( i * (thumbButton.width + 25)) +60;
                        thumbButton.y        = -100 - (i * 10);
                        thumbButton.thumbId = i ;

                        TweenMax.to(thumbButton, .75, { bezier:[ { y:25} ], delay: i*0.02, ease:Bounce.easeOut});
                        
                        thumbButton.create(thumbPath);
                        thumbButton.addEventListener(ThumbButtonEvent.LOADING, LoadingThumb);
                        
                    
                        thumbButton.addEventListener(MouseEvent.CLICK, createPicture);
                        thumbButton.addEventListener(MouseEvent.CLICK, holdThumbDown);
                        thumbButton.addEventListener(MouseEvent.MOUSE_OVER, Over);
                        thumbButton.addEventListener(MouseEvent.MOUSE_OUT, Out);

                        addChild(thumbButton);     
                    }
            
            isThumbAdded = true;
            }

Any idea will be very appreciated… :beer2: