Posted by Jeckyl on 02/06/07 11:31
I can't get to a server to upload a SWI or SWF .. but if you put this script
on your shape, you'll get some nice floating...
>>
onLoad() {
//
// easing
ease = 0.99;
//
// no movement to start with
movetox = _x;
movetoy = _y;
//
// we have two points following a semi-random
// path, and position the object at midpoint
// rotating based on angle between the points
//
// random start position
tx1 = random()*360; // starting time for x
ty1 = random()*360; // starting time for y
tx2 = random()*360; // starting time for x
ty2 = random()*360; // starting time for y
//
// limits for movement
dx = 23; // how far can it move sideways
dy = 17; // how far can it move up and down
//
// speed of mvement
vx = 5; // how fast does it move in x
vy = 3; // how fast does it move in y
//
// position of our two points
x = _x; // starting y
y = _y; // starting y
//
// how much rotation
a = 0.15; // smaller means less rotation
}
onEnterFrame() {
//
// move the two points
xnew1 = x-_width/2 + dx*sindeg(tx1);
ynew1 = y + dy*sindeg(ty1);
xnew2 = x+_width/2 + dx*sindeg(tx2);
ynew2 = y + dy*sindeg(ty2);
//
// object is at midpoint
_x = (xnew1+xnew2)/2;
_y = (ynew1+ynew2)/2;
//
// rotate based on angle between
_rotation = atan2deg(ynew2-ynew1,xnew2-xnew1)*a;
//
// randomness
tx1 += vx*(0.5+random()*0.5);
ty1 += vy*(0.5+random()*0.5);
tx2 += vx*(0.5+random()*0.5);
ty2 += vy*(0.5+random()*0.5);
//
// ease movement
x = movetox-ease*(movetox-x);
y = movetoy-ease*(movetoy-y);
}
>>
NOTE .. if you set movetox and movetoy to some other value, then the object
with this script will flaot its way over there
--
Jeckyl
[Back to original message]
|