-
[F8] Moving an MC in the opposite direction of mouse move
Hi,
Does anybody know how to make a Movie Clip go in the opposite direction that the mouse goes in on a ratio? (e.g. when you move your mouse right the movie Clip slightly left)
Here is a pretty good example of what I am looking for.
I've tried
code:
Xcenter = 275;
Ycenter = 200;
_root.onEnterFrame = function(){
_root.bg_mc._x = Xcenter - _root.xmouse;
_root.bg_mc._y = Ycenter - _root.ymouse;
}
But it did'nt work at all, could somebody please help me?
I'd be grateful for any help
-
Xcenter = 275;
Ycenter = 200;
_root.onEnterFrame = function(){
_root.bg_mc._x = Xcenter - _xmouse;
_root.bg_mc._y = Ycenter - _ymouse;
}
you simply did not use the correct mouse function
-
Originally Posted by alotan
Xcenter = 275;
Ycenter = 200;
_root.onEnterFrame = function(){
_root.bg_mc._x = Xcenter - _xmouse;
_root.bg_mc._y = Ycenter - _ymouse;
}
you simply did not use the correct mouse function
What do you mean? Do I have to use the onMouseMove function?
--EDIT--
It works now, thanks, but is there any way to stop it from going off the stage, here's the .fla file
Last edited by lewys93; 11-02-2006 at 08:18 AM.
-
Originally Posted by alotan
you simply did not use the correct mouse function
instead _root.xmouse use _xmouse
-
thanks for your help but this has lead me to another problem, when I move the mouse to the right, you can see the background of the flash file
-
Originally Posted by lewys93
thanks for your help but this has lead me to another problem, when I move the mouse to the right, you can see the background of the flash file
I've fixed that now, but does anybody know how to get this to work on different layers? i.e Getting things closer up to move across faster, and things further away moving slower?
-
on(|EnterFrame){
_root.closer_mc._x = Xcenter - _xmouse * 2 ;
_root.closer_mc._y = Ycenter - _ymouse * 2;
_root.far_mc._x = Xcenter - _xmouse ;
_root.far_mc._y = Ycenter - _ymouse;
}
-
Thank you for your help, the final code I made is:
code:
Xcenter = 500;
Ycenter = 300;
_root.onMouseMove = function(){
_root.bg_mc._x = Xcenter - _xmouse;
_root.fg_mc._x = Xcenter - _xmouse *1.5;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|