Random motion but floating

I have been trying to tweak the random motion tuts here. What I want to accomplish is a round motion of a clip lets say a sparkle, but I want to appear that it is floating like driven by the wind. I know this sounds crazy but is it possible?? and if yes does anyone have a snippet or a tut I can check out?

:-\
I can’t do better than this: http://www.hot.ee/syko/inertscreensaver.swf
:-\hey maybe I can do better than that…
:o but I do’t have much time…
tell me what I should add to the swf

that is a very cool effect. What mainly dont want to happen in the swf. Is the appearance of a pause and for the motion to be slower and more fluid. Not to sound all poetic but like a feather in the wind. I know it is asking alot but for this project I am working on it would be cool plus I wanna learn how to do it.

What mainly dont want to happen in the swf. Is the appearance of a pause

??? what pause ???
ok but you undestand that a feather-like thingy flying in the wind is very very very very very very very very very very very very very very very very very very very very :*( very very very very very very very very very very very very very very very very very very very very hard if it’s not impossible to do…

Ys I do know it sounds very impossible my imagination out stretches my abilities somtime at least with flash. In 3d I can make almost anything happen. But on your example when it changes direction I kinda notice a pause. If I could achieve what you achieved just alittle more fluid that would be great. Yours is still very cool and I would much like to view the fla.

I guess you could try and give it a random force (I heard it’s called brownian force…). Wait a bit, I’ll make an example for you.

pom :asian:

ilyas you are a life saver. Thank You very much.

If you’re using MX:

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 *= (this.frictionX=.96));
	this._y += (this.velY *= this.frictionX);}
_root.createEmptyMovieClip("ball",0)._visible=0;
ball.lineStyle(30,0,100);
ball.lineTo(.15,.45); 
for (var p=1;p <= (nClip=10);p++) 
	mc=ball.duplicateMovieClip("ball"+p,p,{centx:(radius=100)*Math.cos(p*Math.PI*2/nClip),centy:radius*Math.sin(p*Math.PI*2/nClip),onEnterFrame:effect});

This is not exactly what you wanted becaus it follows the mouse, but it does move smoothly around. See if you can do something with that. If you can’t, well, just post :slight_smile:

pom :asian:

I feel I need to explain this a bit:
centerX and centerY are the point towrds which the point are going.
the strange if test returns 1 every 5 frames so that the direction of the random force changes every 5 frames.
brownX and brownY are the random intensity of the force.
Afterwards, it’s just an elastic motion as explained in the tutorial on this site (k=.002).

Does this help?

pom :asian:

OK, version 2.0:

/*
Motion prototype. brown is the random force, changing direction and intensity
every 15 frames. vel is the elastic force towards centx and centy.
*/
MovieClip.prototype.effect=function(){
	if (!(this.loop=(++this.loop)%(15))) {
		this.brownX = (Math.random() - .5) * .75;
		this.brownY = (Math.random() - .5) * .35;}
	this.velX += (-.002 * (this._x - this.centx)) + this.brownX;
	this.velY += (-.002 * (this._y - this.centy)) + this.brownY;
	this._x += (this.velX *= (this.frictionX=.96));
	this._y += (this.velY *= this.frictionX);}

/*This creates the graphic*/

_root.createEmptyMovieClip("ball",0)._visible=0;
ball.lineStyle(30,0,100);
ball.lineTo(.15,.45); 

/*This duplicates the graphic, defines centx and centy and applies the 
prototype*/
for (var p=1;p <= (nClip=10);p++) 
	ball.duplicateMovieClip("b"+p,p,{centx:Math.random()*500,centy:Math.random()*400,onEnterFrame:effect});

pom :asian:

i don’t know if it helps, but i posted a reply similar to this called smooth random motion, or something like that. also, here’s a clip of what i did.

http://www.geocities.com/randommovement2002

Version 3.0: a grid :stuck_out_tongue: Click to make it move, click again to steady

MovieClip.prototype.effect=function(){
	if (!(this.loop=(++this.loop)%(15))) {
		this.brownX = (Math.random() - .5) * .75;
		this.brownY = (Math.random() - .5) * .35;}
	this.velX += (-.002 * (this._x - this.centx)) + this.brownX;
	this.velY += (-.002 * (this._y - this.centy)) + this.brownY;
	this._x += (this.velX *= (this.frictionX=.96));
	this._y += (this.velY *= this.frictionX);}

_root.createEmptyMovieClip("ball",0)._visible=0;
ball.lineStyle(30,0,100);
ball.lineTo(.15,.45); 

for (var p=1;p <= (nClip=10);p++) 
	ball.duplicateMovieClip("b"+p,p,{centx:Math.random()*500,centy:Math.random()*400,onEnterFrame:effect});

pom :asian:

Nice, Twinkle, but there’s still a pause…

Well, once again i don’t know if it’ll help, but here goes my code i used for my movie
Just create a shape and put this code in its actions:
onClipEvent (load)
{
speed = .1;
xLocation = 0;
yLocation = 0;
}
onClipEvent (enterFrame)
{
if (Math.ceil(this._x) == xLocation && Math.ceil(this._y) == yLocation)
{
xLocation = random(390);
yLocation = random(190);

}
this._x = (this._x + (xLocation - this._x) * speed);
this._y = (this._y + (yLocation - this._y) * speed);
this._rotation = ((yLocation - this._x) + (xLocation - this._y)/2);
}

if you wanted to take out the pause between movements, add an if statement that checks to see how close the clip is to the random location, and if it’s about 5 or 10 px away, have it go ahead and do the random thing again. If someone else wants to do actual code for that go ahead. I don’t have time.
here’s the page for it if you didn’t get it earlier
http://www.geocities.com/randommovement2002

DUUUUDDDE…SSSSWWWWWEEEET…this is eactly what I was looking for now I am going to study it and try to recreate it and use it for my devilish deeds…I really appreciate the time invested…Everytime I post here I learn something new and that is a good thing…Thanks ALL

if u wanted to u could make it so one of the clips is the center and the others swarm around that clip… :slight_smile:

hey bezzer how would one go about doing that?? Please share

well i’m using a random motion script thats under a movieclip.This acts as a center for the other thingy… the other thingy…the one that looks like its floating uses bit-101’s elasticity script to give it a smooth motion… well here it is…

ehm… this is getting a little complicated… +I’m on a non-flashed computer because my computer is not where it’s supposed to be…
well… nice going ilyas and winkle and somebody I didn’t mention :slight_smile:

Nice, Bezzer… Weird motion, but nice scripting :stuck_out_tongue: