TwelvestoneFlash

Advanced Sliding | mc related to mouse position


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
penlix
 
2007-10-25

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

penlix
 
2007-10-25

Well, I kind of got it in Kirupa Forums, I hope it's ok if I post the link to the topic:

Simulated Multiplane Camera

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.

DontBogartMe
 
2007-10-25

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.

penlix
 
2007-10-30

Yep, ofcourse, Download File

K.

DontBogartMe
 
2007-10-30

.........far.....too.....lazy.........to........download....................need.....a..........swf k

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Advanced Sliding | mc related to mouse position