Pomegranate Fractal

Alright this is my last submission for a little bit lol. I just started playing with fractals again.


_root.createEmptyMovieClip("container",1);
var d = 1;
var radius = 5;
wind = 0;
var circles = [];
var MAXITER = 4;
function addCircle(x, y, scale) {
    var mc = container.attachMovie("Circle", "circle"+d, d++);
    mc._x = x;
    mc._y = y;
    mc.vx = Math.random()-.5;
    mc.vy = Math.random()-.5;
    mc.t = 0;
    mc._xscale = mc._yscale=scale;
    mc.colorobj = new Color(mc.coloroverlay);
    circles.push({x:x, y:y, r:.25*scale, mc:mc});
    mc.setHue(.3);
    return mc;
}
MovieClip.prototype.setHue = function(x) {
    //x = 0 - 1
    x = Math.max(x*2*Math.PI, 0.01);
    r = 128+128*Math.cos(x);
    g = 128+128*Math.cos(x+Math.PI*2/3);
    b = 128+128*Math.cos(x+Math.PI*4/3);
    var hex = r << 16 | g << 8 | b;
    this.colorobj.setRGB(hex);
};
var N = 0;
var startpoint = 0;
function iterate0() {
    N++;
    var n = circles.length;
    for (i=startpoint; i<n; i++) {
        var base = circles*;
        base.mc.children = [];
        var t0 = xt/500*2*Math.PI*N;
        var t = t0;
        for (var i2 = 0; i2<3; i2++) {
            t += Math.PI*2/3;
            var c = addCircle(base.x+base.r/2*Math.cos(t), base.y+base.r/2*Math.sin(t), base.r*1.6);
            c.setHue(N/10);
            base.mc.children.push(c);
        }
    }
    startpoint += Math.pow(3, N-1);
}
function iterate() {
    N++;
    var n = circles.length;
    lim = 1;
    for (i=0; i<n-Math.pow(3, MAXITER); i++) {
        if (i>lim) {
            N++;
            lim += Math.pow(3, N);
        }
        var base = circles*;
        var t = xt/100*N*N;
        for (var i2 = 0; i2<3; i2++) {
            t += Math.PI*2/3;
            var refcircle = base.mc.children[i2];
            refcircle._x = base.mc._x+base.r/2*Math.cos(t);
            refcircle._y = base.mc._y+base.r/2*Math.sin(t);
        }
    }
}
var xt = 0;
onEnterFrame = function () {
    onMouseMove();
    xt += 1;
};
function init() {
    circles = [];
    N = 0;
    _root.createEmptyMovieClip("container",1);
    addCircle(250, 150, 500).setHue(0);
    for(var i =0;i<MAXITER;i++){
        iterate0();
        }
    }
init();
//iterate();
onMouseMove = function () {
    N = 0;
    iterate();
};

>Preview Here<