Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beaded curtain

Status
Not open for further replies.

gilc

MIS
Feb 20, 2002
36
HK
hi every one,
i am making curtain beads( beads curtian) and i want the beads of the curtain to sway a bit, like a light wind displaces them, now, i want to know how can i do it , i tried several ways, but all are not perfect or close to it , and they require a guide layer ans many guided layers, (one layer for one bead ), is there a better way ,,
thank u
gilc
 
You could do it with actionscript. Each bead would be a movie clip which has its position altered by a slight amount every frame (script is below), you could then use the drawing API to draw lines which connect the beads together.

Code:
MovieClip.prototype.drawCircle = function(x, y, r, col) {
	var endX, endY, controlX, controlY;
	arcs = 8;
	var arcAngle = (360/arcs)/180*Math.PI;
	var controlDist = r/Math.cos(arcAngle/2);
	this.moveTo(x+r, y);
	this.lineStyle(2, col);
	this.beginFill(col, 50);
	for (var i = 1; i<=arcs; i++) {
		endX = x+r*Math.cos(i*arcAngle);
		endY = y-r*Math.sin(i*arcAngle);
		controlX = x+controlDist*Math.cos(i*arcAngle-arcAngle/2);
		controlY = y-controlDist*Math.sin(i*arcAngle-arcAngle/2);
		this.curveTo(controlX, controlY, endX, endY);
	}
	this.endFill();
};
//
centre = 275;
waveSpeed = .1;
waveMax = centre+15;
waveMin = centre-15;
//
for (var i = 0; i<4; i++) {
	this.createEmptyMovieClip('bead'+i, i);
	this['bead'+i].drawCircle(centre, i*40, 15, 0xCC0000);
}
//
this.onEnterFrame = function() {
	waveSpeed *= (waveX>waveMax || waveX<waveMin) ? -1 : 1;
	for (var i = 0; i<4; i++) {
		this['bead'+i]._x += waveSpeed*i*i;
	}
	waveX = centre+this['bead3']._x;
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top