Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to make a group of objects follow the mouse

New Here ,
Nov 18, 2012 Nov 18, 2012

I'm trying to get a group of objects to follow the mouse. I have 17 objects, 16 of which are arranged in a circle around the 17th. When the mouse moves, I need the central object to follow it smoothly. Once the central object breaks the circle the other objects need to start following it in the most fluid way possible. When the mouse stops moving, the objects need to rearrange themselves in the same relative positions as before the mouse started moving. Is it also possible to set a time delay so that 10 seconds after the mouse stops moving, the movie goes back to the start screen? I have no idea how to do all of this not having any knowledge of coding. Answers built for the Completely Clueless would be best but any help would be greatly appreciated. Thanks!

TOPICS
ActionScript
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 19, 2012 Nov 19, 2012

You are not likely to be handed a solution due to the potential intracies of managing that many objects in the way you describe, but here's some starter info... 

To make an object follow the mouse you can make use of the mouseX, mouseY properties, as well as the object's x and y properties. 

To have it happen constantly, you need to have something that constantly adjusts the values to be the same - this is often accomplished using an ENTER_FRAME event listener/handler. 

To have it done smoothly can involve adding some easing to soften the motion a bit, meaning the change of position of the object relative to the mouse position is not immediate, but it lags slightly and catches up to it.

What you oughta do is search Google for tutorials using search terms such as "AS3 follow mouse easing" .  Here one result from that search, and you will find numerous others as well along with it.

http://www.freeactionscript.com/tag/follow-mouse-with-easing/

Maybe after you understand how to have one object folling the mouse, you can figure out a way to make the other 16 objects follow the first object.  You might think in terms of grouping the other objects and moving them as a whole unless you intend to have each one indepenetly decide how it will follow.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 19, 2012 Nov 19, 2012

Thanks Ned! Will try and work it out with the tutorials!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 19, 2012 Nov 19, 2012
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines