Help with particle collision issue please!

Hi, i’ve just recently picked up learning as3 and was doing some practice via making random things, I ended up making a program that generates particles at the location of your mouse when you click and sends them flying in random directions. I tried making them bounce off of the stage perimeters but instead a small “box” was created around the mouses location that contains all of the particles… sorry for the long winded explanation i’m just trying to give as many detals as possible :puzzled: heres the code

package {
    import flash.display.*;
    import flash.events.*;


    public class colorRandom extends MovieClip {
        private var my_MC:MovieClip;
        private var index:Array;
        private var i,r,maxParticles, left, top, right, bottom:Number;
        
        public function colorRandom(rootMovie:MovieClip) {
        my_MC = new MovieClip();
        index = new Array();
        maxParticles = 100;
        top = rootMovie.parent.height - rootMovie.parent.height;
        left = rootMovie.parent.width - rootMovie.parent.width;
        right = rootMovie.parent.width;
        bottom = rootMovie.parent.height;
        rootMovie.addChild(my_MC);
        rootMovie.parent.addEventListener(MouseEvent.MOUSE_DOWN, explosion);
        addEventListener(Event.ENTER_FRAME, moveParticles);

        }
        
        private function explosion(parent){
            createParticles();
            maxParticles = 100;
            
        }
        
        private function moveParticles(e:Event){
            for(i = index.length -1; i > 0; i--){
                index*.x += index*.pX;
                index*.y += index*.pY;
                if(index*.y <= 0){
                    
                    index*.pY = Math.abs(index*.pY);
                    index*.pY = index*.pY * 0.7;
                }
                if(index*.x <= 0){
                    index*.pX = Math.abs(index*.pX);
                    index*.pX = index*.pX * 0.7;
                }
                if(index*.x >= 50){
                    index*.pX = index*.pX * -1;
                    index*.pX = index*.pX * 0.7;
                }
                if(index*.y >= 50){
                    index*.pY = index*.pY * -1;
                    index*.pY = index*.pY * 0.7;
                }
                index*.life --;
                if(index*.life <= 0){
                    destroyParticle(i);
                }
                
                
            }
        }
        
        private function createParticles(){
            while(maxParticles > 0){
                var particlebase:particleBase = new particleBase();
                var particle:Shape = new Shape();
                particlebase.life = 40;
                particlebase.pX = (Math.random()*10) - (Math.random()*10);
                particlebase.pY = (Math.random()*10) - (Math.random()*10);
                if(Math.abs(particlebase.pY) <1 && Math.abs(particlebase.pX)<1){
                    particlebase.pX = 2;
                    particlebase.pY = 2;
                }
                particlebase.graphics.beginFill(Math.random()*0x999999);
                particlebase.graphics.drawCircle(mouseX,mouseY,Math.random()*3);
                particlebase.addChild(particle);
                my_MC.addChild(particlebase);
                index.push(particlebase);
                maxParticles--;
            }
        }
        
        private function destroyParticle(i2:Number){
            my_MC.removeChildAt(index[i2]);
            index.splice(i2, 1);
        }
    }
}

about the unused top/left/down/right vars… i was trying to use them but don’t actually know how to reference the stage from an external as file properly, if you could tell me how to do that as well it would help >.< thanks!