Random shape tween

is there a script or method that would allow you to randomly shape tween a shape? in other words i would have no control over what shape the turns out to be?

With a lot of math and the drawing API in MX, but well… you have to be really good at both of those to actually make it compose a final shape other than a square.

IMO. Maybe someone else knows an easier way.

Well, this is not so difficult, really. All you have to do is have a certain number of points move randomly, and then draw lines between the points. No math involved :slight_smile:

Yeah… for you it is easy… Mr. AS Master :stuck_out_tongue:

Picturing in my head it seems difficult, but I was assuming that he wanted actual shapes, like defined, instead of a random “mess”.

Pom that sounds really interesting, do you think you could throw together a lil fla? :-\

Here’s something I did for the bit contest. I cleaned the code a bit and I used curveTo but the idea is there:

/*** Variables ***/
friction=.96;
nClip=10;
radius=100;

/*** "Random elasticity" prototype inspired from Robert Penner ***/
MovieClip.prototype.effect=function(){
	this.centerX = _root._xmouse+this.centx;
	this.centerY = _root._ymouse+this.centy;
	if (!(this.loop=(++this.loop)%(5))) {
		this.brownX = (Math.random() - .5) * .35;
		this.brownY = (Math.random() - .5) * .35;}
	this.velX += (-.002 * (this._x - this.centerX)) + this.brownX;
	this.velY += (-.002 * (this._y - this.centerY)) + this.brownY;
	this._x += (this.velX *= friction);
	this._y += (this.velY *= friction);
};

/*** I draw a dot to make it clearer ***/
_root.createEmptyMovieClip("ball",0);
ball.lineStyle(5,0,100);
ball.lineTo(0.15,0.45);

/*** Duplicates and positions all dots in circle ***/
for (var p=0;p < nClip;p++){
	mc=ball.duplicateMovieClip("ball"+p,p+1);
	mc.centx=radius*Math.cos(p*Math.PI*2/nClip);
	mc.centy=radius*Math.sin(p*Math.PI*2/nClip);
	mc.onEnterFrame=effect;
}

/*** Draws the fill ***/
_root.onEnterFrame=function(){
	mid=new Array();
	for (var j=0;j < nClip;j++){
		mid.push({x:(_root["ball"+j]._x+_root["ball"+(j+1)%nClip]._x)/2,y:(_root["ball"+j]._y+_root["ball"+(j+1)%nClip]._y)/2});
	}
	this.clear();
	this.lineStyle(1, 0, 100);
	this.beginFill(0x384862, 50);
	this.moveTo(mid[0].x, mid[0].y);
	for (j=1;j <= nClip;j++)
		this.curveTo(_root["ball"+j%nClip]._x, _root["ball"+j%nClip]._y, mid[j%nClip].x, mid[j%nClip].y);};

pom :crazy:

With lines:

/*** Variables ***/
friction=.96;
nClip=10;
radius=100;

/*** "Random elasticity" prototype inspired from Robert Penner ***/
MovieClip.prototype.effect=function(){
	this.centerX = _root._xmouse+this.centx;
	this.centerY = _root._ymouse+this.centy;
	if (!(this.loop=(++this.loop)%(5))) {
		this.brownX = (Math.random() - .5) * .35;
		this.brownY = (Math.random() - .5) * .35;}
	this.velX += (-.002 * (this._x - this.centerX)) + this.brownX;
	this.velY += (-.002 * (this._y - this.centerY)) + this.brownY;
	this._x += (this.velX *= friction);
	this._y += (this.velY *= friction);
};

/*** I draw a dot to make it clearer ***/
_root.createEmptyMovieClip("ball",0)._visible=0;
ball.lineStyle(5,0,100);
ball.lineTo(0.15,0.45);

/*** Duplicates and positions all dots in circle ***/
myClips=new Array();
for (var p=0;p < nClip;p++){
	myClips[p]=ball.duplicateMovieClip("ball"+p,p+1);
	myClips[p].centx=radius*Math.cos(p*Math.PI*2/nClip);
	myClips[p].centy=radius*Math.sin(p*Math.PI*2/nClip);
	myClips[p].onEnterFrame=effect;
}

/*** Draws the fill ***/
_root.onEnterFrame=function(){
	this.clear();
	this.lineStyle(1, 0, 100);
	this.beginFill(0x384862, 50);
	this.moveTo(myClips[0]._x, myClips[0]._y);
	for (j=1;j <= nClip;j++){
		this.lineTo(myClips[j%nClip]._x, myClips[j%nClip]._y);
	}
}

holy cr*p, how on earth do you come up with code like this?! Tell me, I want to learn even if its going to take me a million yrs! :o

It really looks harder than it actually is. If we look at it:
[list][]The effect prototype is the hardest part. If you’ve read the elesticity tute, you should recognize it easily, but the loop thinggy is a bit tricky. This is the part I borrowed from Robert Penner by the way. What it does is this: every 5 frames, Flash choses a random force for each clip, what is called brown in the code. This force is of course added to the elastic force to give vel[]We put all our clips in an array to manipulate them more easily[*]The main enterFrame runs through the array and draws a line between 2 consecutive clips.[/list]And voilà.

pom :crazy:

That is amazing, I hope you don’t mind if I tinker with your code. I’m gonna try to see if I can make something different or add to it, but thanks a lot for the demonstration. I seriously need to cut back on designing a bit and concentrate more on coding. Thanks again. =)

Well thanks :beam:
And please do whatever you like, I’d love to see what you’ll do with it. [SIZE=1]And you’re rigth, coding can be fun too. I’ve just bought myself Fresh Flash by the way…[/SIZE]

Woo, I like this one too:

/*** Draws the fill ***/
depth=100;
_root.onEnterFrame=function(){
	var mc=this.createEmptyMovieClip("c"+(++depth),depth);
//	this.clear();
	mc.lineStyle(1, 0, 100);
	mc.beginFill(0x384862, 50);
	mc.moveTo(myClips[0]._x, myClips[0]._y);
	for (j=1;j <= nClip;j++){
		mc.lineTo(myClips[j%nClip]._x, myClips[j%nClip]._y);
	}
	mc.onEnterFrame=function(){
		this._alpha-=10;
		if (this._alpha <=0) this.removeMovieClip();
	}
}

lol that is awesome!! its like an onion skin effect!! I like that. :stuck_out_tongue:

Ilyas… you have no idea how much you make me want to cry.

  1. Because your so good and I know it will take me a billion years before I reach your level :frowning:

  2. Because your stuff is just soooo beautiful :slight_smile:

:crazy:
i dont know whether to cream my pants or **** myself that is awesome

:stuck_out_tongue: :beam:

thanks! that’s awesome… it’s almost exactly what i was looking for! i want to try and get it stationary though instead of following the mouse around! thanks again!