Hi,
I have been building a movie and I am using the following script to move my mc left or right. However, this looks pretty simple and I was really looking to reach the level of Vodafone this movie's animation, where the mc stops sliding, when the mouse is not moving
This is the code I am using so far and it works fine, but with no easing, and it moves continuously..:
xcenter = 250; speed = 1/70; videos.onEnterFrame = function() { var distance = _root._xmouse-xcenter; videos._x -= (distance*speed); if (videos._x<= -100) { videos._x = -100; } if (videos._x>=0) { videos._x = 0; } };
Thanks in advance for your help,
Kostas
Well, I kind of got it in Kirupa Forums, I hope it's ok if I post the link to the topic:
That person posted this piece which does it all..
var targetx:Number = 0; var targety:Number = 0;
onEnterFrame = function () {
targetx = -(((Supper._width - Stage.width) / Stage.width) * _xmouse);
targety = -(((Supper._height - Stage.height) / Stage.height) * _ymouse);
var dx = targetx - Supper._x;
var dy = targety - Supper._y;
vlen = Math.sqrt(dx * dx + dy * dy);
if(vlen < 0.1) {
Supper._x = targetx;
Supper._y = targety;
} else {
dx = dx / vlen;
dy = dy / vlen;
dx *= vlen * 0.2;
dy *= vlen * 0.2;
Supper._x += dx;
Supper._y += dy;
}
}
K.
you got a SWF online we can gawk at? Or maybe some explanation of what the code's doing so we don't have to try to figure it out ourselves? I know you've fixed your problem... it's just nice to have a working version viewable for these things.
Yep, ofcourse, Download File
K.
.........far.....too.....lazy.........to........download....................need.....a..........swf 