Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Moving multiple objects in circle (Flash)


  • Please log in to reply

#1
Fenor

Fenor

    Trusted Tech

  • Retired Staff
  • 5,236 posts
Hey guys. I have a problem here. I am trying to make multiple movie objects rotate in a circle. I have the code to make an object move in a circle, but when I try to add that code to another object it follows the same path. What I would like to know, is how do I alter the beginning location of the second object so that it starts in a different location then the other object so that both are visible moving in a circle.

Below is the code I am using for the object:
onClipEvent(load)
{
  cx = Stage.width/2; // coords of center of circle (center of screen, in this case)
  cy = Stage.height/2;

  rad = 120; // radius of circle

  speed = 8; // speed of travel (seconds to make a complete circuit)
  speedScale = (0.001*2*Math.PI)/speed;
}

onClipEvent(enterFrame)
{
	  var angle = getTimer()*speedScale;
	this._x = cx + Math.sin(angle/2)*rad;
	this._y = cy + Math.cos(angle/2)*rad;
}

Thanks for any help I receive! :whistling:

Fenor
  • 0

Advertisements


#2
Fenor

Fenor

    Trusted Tech

  • Topic Starter
  • Retired Staff
  • 5,236 posts
Nevermind guys/gals. I decided to go a different route and am using a Motion Guide and tweening the object around a circular motion guide.

Fenor
  • 0

#3
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Good choice :whistling:, I was about to write about that. But nice code though.
  • 0

#4
Blissd

Blissd

    New Member

  • Member
  • Pip
  • 1 posts
Hey guys,

I'm also after a solution to a similar issue.

I've incorporated the code that Fenor pasted and it works fine; I'd like to get multiple objects rotating though.

My reason for using the actionscript is that the object moves around a path and doesn't actually rotate.

So, if I have the word 'Hello', I need it to rotate around a circle while staying horizontal. If I use a path the text goes upside down when it follows the path.

Any assistance would be greatly appreciated.

Cheers!
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP