p = 30000;

n = 25;

r = 14 /100;

function createBox(container, clipName, clr, w, h, x, y) {

var x1 = (x == undefined) ? 0 : x;

var y1 = (y == undefined) ? 0 : y;

var x2 = x1+w;

var y2 = y1+h;

container.createEmptyMovie

container[clipName].beginF

container[clipName].moveTo

container[clipName].lineTo

container[clipName].lineTo

container[clipName].lineTo

container[clipName].endFil

}

// var names as in the website... clearer

var n:Number, p:Number, z:Number, a:Number;

z = r+1;

a = (p*r)/(1-Math.pow(z, -n));

trace("Annual payment: "+Math.ceil(a));

year = new Array();

year[1] = (p*z)-a;

trace("year 1 debt: "+Math.floor(year[1]));

for (var i = 2; i<=n; i++) {

year[i] = (year[i-1]*z)-a;

trace("year "+i+" debt: "+Math.floor(year[i]));

}

for (var i = 1; i<=n; i++) {

createBox(_root, "debt"+i, 0x00ff00, 10, -((year[i]/p)*200));

createBox(_root, "equity"+i, 0xff0000, 10, 200-((year[i]/p)*200));

_root["debt"+i]._x = 20*i;

_root["debt"+i]._y = 200;

_root["equity"+i]._x = 20*i;

_root["equity"+i]._y = 200-_root["equity"+i]._hei

}