What influences x and y coords display?

I have a function which attaches a bunch of MCs onto another MC and then calls a function which also attaches a bunch of MCs onto another MC. The problem is as soon as i call both functions the second function puts the MCs into lower right corner. I checked the coords and theyre OK.
When i disable the first function the second works fine. I tried putting the second in front of the first but the result is the same. Also if i disable the second one the first one works fine.
I have no idea what could be wrong and i would be really glad if someone could help me out!

Here are the functions:


        var i:Number;
        var j:Number;

        for (i = 0; i<stKaset; i++) {
            for (j = 0; j<stKasetVer; j++) {
                kx=i*43+(i+1)*presledekHor;
                ky=j*29+(j+1)*presledekVer;                
                
                k = ref.attachMovie("kaseta", "kaseta"+i+""+j, ref.getNextHighestDepth());
                k._x = kx; 
                k._y = ky; 
            }
        }
        ref._x = zac_X;
        ref._y = zac_Y;

       izrisiLinije(lamelaGladka); //this is the second function



function izrisiLinije(presledek:Number){
    var stLinij = zaokrozi(visinaPr/presledek);
    var ref = this.vzorec_vrat;
    var i=0;
    var koo_y = zac_Y;
        
    for(i=0;i<stLinij;i++){
        koo_y +=presledek;
            
        var l = ref.attachMovie("locilo", "linija"+i, ref.getNextHighestDepth());
        l._x = zac_X+2;
        l._y = koo_y;
        l._width = sirinaPr-2;
    }//for zanka
};