Project: Age of Empire Help

ok i know im demanding a lot but can sum1 explain this code to me over here

i got this from nathan99’s work im trying to expand it. thanks a lot nathan99 and if u r here could u help a felow member out? this is the code for the stable i cannot understand

i = 0;


function createhorse() {
    _root.attachMovie(_root.u, "horse"+i, this._y, {_x:crtX, _y:crtY});
    _root["horse"+i].menlist = "horse";
    _root["horse"+i].k = i;
    _root["horse"+i].onEnterFrame = function() {
        this.swapDepths(this._y);
        if (this.hitTest(_root.smile) && !hit) {
            hit = true;
            if (!_root["selected"+this.k]) {
                _root.men.buttons.gotoAndStop(_root.u);
                _root["selected"+this.k] = true;
            } else {
                _root["selected"+this.k] = false;
            }
        }
        if (!this.hitTest(_root.smile) && _root.downd) {
            hit = false;
        }
        if (_root["selected"+this.k] && _root.men.buttons._currentframe == 3) {
            _root.men.buttons.gotoAndStop(_root.u);
            this.gotoAndStop("select");
            this.onMouseDown = function() {
                if (!_root.men.hitTest(_root._xmouse, _root._ymouse, true) && _root["selected"+this.k]) {
                    _root.circ.removeMovieClip();
                    xpt = _root._xmouse;
                    ypt = _root._ymouse;
                    _root.attachMovie("circ", "circ", _root.getNextHighestDepth(), {_x:xpt, _y:ypt});
                }
            };
            if (xpt>this._x+5) {
                this._x += 5;
                this._xscale = 100;
                moving = true;
            } else {
                moving = false;
            }
            if (xpt<this._x-5) {
                this._x -= 5;
                moving = true;
                this._xscale = -100;
            } else {
                moving = false;
            }
            if (ypt>this._y+5) {
                this._y += 5;
                moving = true;
            } else {
                moving = false;
            }
            if (ypt<this._y-5) {
                this._y -= 5;
                moving = true;
            } else {
                moving = false;
            }
            if (!moving) {
                _root.circ.removeMovieClip();
            }
        } else {
            this.gotoAndStop(1);
            _root["selected"+this.k] = false;
        }
    };
    i++;
    queued = false;
    dif = 0;
    clearInterval(proger);
    clearInterval(inty);
}
function progint() {
    dif += 100;
    progress = timelim-dif;
    bar._xscale = progress/timelim*100;
}

:puzzle::puzzle::puzzle:

and nathan99 again a very great job but im trying to work this game out plz help… im not ripping u for anything all credit goes to u! i just wanna know how the code above works!

:beam:

and only one more thing how do u make it so that when the horse is created he does not have the same no. i.e to say attach movie clip. horse or sum thing and u assign a no. say 0 for the first horse and the max limit is 20 so you’ll get horse1, horse2,horse3 etc. :-/:hugegrin:

P.S:moreover i saw that there is some glitch going on when u create horses from two diffrent stables.:ear: plz i await ur advice to proceed wid this project

anyone lend a hand? oh and for that FIFA proj. my friend helped me out there but i can give all credit to DangerousDan for starting us in this proj. u see im planning ot make sum type of game-o-cd… my friend provides.:tb::tb: