MovieClip.prototype.drawCircle = function(r, x, y, line, fill) {
	this.moveTo(x+r, y);
	a = Math.tan(22.5 * Math.PI/180);
	this.lineStyle(1, line, 100);
	this.beginFill(fill, 100);
	for (var angle = 45; angle<=360; angle += 45) {
		// endpoint:
		var endx = r*Math.cos(angle*Math.PI/180);
		var endy = r*Math.sin(angle*Math.PI/180);
			  // control:
		// (angle-90 is used to give the correct sign)
		var cx =endx + r*a*Math.cos((angle-90)*Math.PI/180);
		var cy =endy + r*a*Math.sin((angle-90)*Math.PI/180);
		this.curveTo(cx+x, cy+y, endx+x, endy+y);
	}
		this.endFill();
}
	
MovieClip.prototype.drawPetal = function(r, line, fill){
	//this.moveTo(0,y);
	this.lineStyle(1, line, 100);
	this.beginFill(fill, 100);
	this.curveTo(-(r/2), r, x, r);
	this.curveTo((r/2), r, x, y);
	this.endFill();
}

MovieClip.prototype.drawFlower = function(mc, height, petals, line, fill){
	for(i = 0; i < petals; i++){
		n = ["petal" + i];
		//trace(n);
		mc.createEmptyMovieClip(n, i + 10);
		mc[n].drawPetal(height, line, fill);
		mc[n]._rotation += i * (360/petals);
	}
}

j = 0;

_root.onMouseMove = function(){
	j++;
	//trace(j);
	if(j>400){
		j=0;
	}
	
	_root.createEmptyMovieClip('mc'+j, j);
	mc = _root['mc'+j];
	pet = Math.round(Math.random() * 8) + 3;
	//trace(pet);
	mc.drawFlower(mc, 25, pet, 0x000000, 0xFF6699);
	mc.createEmptyMovieClip("heart",9999);
	mc.heart.drawCircle(7, 0, 0, 0x000000, 0xFFFF00);	
	mc._x = _root._xmouse;
	mc._y = _root._ymouse;		
	  
	mc.ydir = Math.random();
	mc.xdir = Math.random();
	
	if(mc.ydir < 0.5){
		t = -1;
	}else{
		t = 1;
	}
	
	if(mc.xdir < 0.5){
		s = -1;
	}else{
		s = 1;
	}
	
	mc.yspeed = 1 + (t * Math.floor(Math.random() * 10));
	//trace(mc.yspeed);
	mc.xspeed = 1 + (s * Math.floor(Math.random() * 10));	
	//trace(mc.xspeed);
	mc.onEnterFrame = function(){
		this._alpha -= 3;
		this._rotation += -10 * this.yspeed;
		//this._yscale -= 10;
		this._y += this.yspeed;
		this._x += this.xspeed;
		if(this._alpha < 0){
			this.removeMovieClip();
		}
	}
}