Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,511 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,739 people online right now. Registration is fast and FREE... Join Now!




onRollOver move x or y position of a movieclip

 
Reply to this topicStart new topic

onRollOver move x or y position of a movieclip

cadeownz
5 Aug, 2008 - 08:28 PM
Post #1

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

hey,
i need a code that makes it so when i rollover a movieclip another movieclip moves in x or y direction. so say i have a box and a circle:
[] (). if i put my mouse over the box [] the circle () moves like this ()-->()
by changing the x position. i know how to make stuff move with key press's but was wondering if it was possible to put ur mouse over something and make another movie clip move. NOT the one i put my mouse over.. Please help, need desperatly for a game im making.
thanks in advance!
pirate.gif pirate.gif rolleyes.gif rolleyes.gif pirate.gif pirate.gif crazy.gif crazy.gif tongue.gif tongue.gif smile.gif smile.gif biggrin.gif biggrin.gif
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: OnRollOver Move X Or Y Position Of A Movieclip
6 Aug, 2008 - 10:49 AM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,026



Thanked: 81 times
Dream Kudos: 1175
My Contributions
I would say make the rectangle (box) have an onrollover and rollout function that initializes the x and y positions of the mouse like so:

CODE
var mouseOn:Boolean = false;
var xi:Number;
var yi:Number;
this.onRollOver = function(){
  mouseOn = true;
  xi = _root._xmouse-this._x;
  yi = _root._ymouse-this._y;
}
this.onRollOut = function(){
  mouseOn = false;
}


Then make the onmousemove function check if the mouseOn if true, if so it should do something (move the circle xc-xi and yc-yi that way it will more the circle when the mouse is over the box but not when it isn't and will only move it relative to the mouse movement.

Go ahead and try to make this function yourself and I will help if you get stuck.
User is offlineProfile CardPM
+Quote Post

cadeownz
RE: OnRollOver Move X Or Y Position Of A Movieclip
6 Aug, 2008 - 08:06 PM
Post #3

New D.I.C Head
*

Joined: 11 Jul, 2008
Posts: 31

---------------The following text probly sounds real nooby-----------------

Hey at first glance i noticed this could not possibly be a mc script. so where should i put it? frame mc? please i need to know lol. But thnx for helping. biggrin.gif biggrin.gif smile.gif biggrin.gif smile.gif biggrin.gif
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: OnRollOver Move X Or Y Position Of A Movieclip
6 Aug, 2008 - 09:11 PM
Post #4

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,026



Thanked: 81 times
Dream Kudos: 1175
My Contributions
This script would go inside of the box mc.

HTH
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 08:56PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month