Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:43:07+00:00 2026-05-24T03:43:07+00:00

I have an object called point that I can move around the screen with

  • 0

I have an object called point that I can move around the screen with my mouse. This object has a vector mapped through it (_v1) using the center of the stage and “point”s x,y location in order to draw the vector (note all of this is working fine). My problem is occurring when I set up was a button that simply sets a value to true if you press it. The idea behind this button is that when pressed, whatever location “point” is at, it will move 1 degree clockwise in a circle around the center of the stage (this is all happening in the frameHandler so I can keep clicking the button to make it continue around the stage). The code I am using is based in an if statement listed below:

if(clockwisePressed) {
    var v1angle:Number = _v1.angle;
    v1angle++; //increase the angle by 1 degree
    if(v1angle>180) {
        v1angle -= 360;
    }
    //Now just move the crosshair and get it ready to be redrawn
    point.x = centerX - _v1.m * Math.cos(v1angle);
    point.y = centerY - _v1.m * Math.sin(v1angle);
    clockwisePressed = false; //remove button pressed boolean
}

So what is happening here is that clockwisePressed has been set to true so this fires off. My vector (_v1) is set up to tell me the angle (already converted from radians to degrees) but it’s a read-only value. So I assign it (_v1.angle) to v1angle so I can mess with it and increase it by 1 so I’m moving clockwise around the center of the stage. Then I just check to make sure that it falls into a range between -180 and 180 (if I trace _v1.angle around the stage, 0 degrees is to the left, 90 degrees is straight up, 180 degrees is to the right, and -90 is straight down). Now using the formula I derived from this thread but converted to work with 0 degrees pointing to the left and the value for Y going up the further down the stage you go, I came up with

x = centerX - radius * cos(angle)
y = centerY - radius * sin(angle)

Now when I make a sample chart on paper and use these values on my calculator, this works like a charm. If I plug in an angle, the radius, and center I get a point right on my circle I draw on a sheet of graph paper. However, when I actually try this in flash, the “point” jumps all over the stage. (Note that _v1.m is just the magnitude of the vector between the center of the stage and “point” which is the same as the radius).

So I trace everything and the values for cos and sin don’t seem to be coming out right. For example, if my angle is -1.9581 and I take the cos of that on my calculator I get something along the lines of 0.9994 but flash traces Math.cos(angle) to be -0.3777. Isn’t using Math.cos(-1.9581) the same as putting -1.9581 into your calculator and hitting cos?

So in the case of my example above, my point.x went from 139.95 to 261.3. Quite a big jump for what was supposed to be 1 degree. So I’m at a loss here as to what is causing this code to fail so drastically. Am I doing something wrong here?

UPDATE: If anyone who searches this topic is interested, below is the corrected code that works:

if(clockwisePressed) {
    var v1RadAngle:Number = Math.atan2(_v1.vy, _v1.vx); //get angle in radians
    v1RadAngle += 0.0174; //increase the angle by ~1 degree more or less
    //Now just move the crosshair and get it ready to be redrawn
    point.x = centerX - _v1.m * Math.cos(v1RadAngle); //_v1.m = radius
    point.y = centerY - _v1.m * Math.sin(v1RadAngle);
    clockwisePressed = false; //remove button pressed boolean
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:43:07+00:00Added an answer on May 24, 2026 at 3:43 am

    The trig functions in Flash expect input in radians, but you’re using degrees. You must convert your degree value to radians before using it:

    var angle:Number = -1.9581;
    var radAngle:Number = angle * Math.PI / 180;
    trace(Math.cos(radAngle)); // 0.9994160815411552
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey. I have an object that has a string property called BackgroundColor. This string
I have a property called IsSecureConnection that is part of my object's interface. This
I have an object that is mapped to a cookie as a serialized base-64
I have a collection of an object called Bookmarks which is made up of
I have a c# object with a property called Gender which is declared as
I have object A which in turn has a property of type Object B
I have an object in a multi-threaded environment that maintains a collection of information,
I have a method that is getting called from multiple threads. Each of the
I have found that Scala always has a natural explanation to anything. Always something
I've got a class called Request . At some point in that class I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.