Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash


ActionScript 3.0 :: Moving A Line In A Circle?

I am trying to move a line around in a circle, around a fixed point (not 0,0). As in the way a clock hand moves around with one end at the middle and the other end traveling in a circle. I tried the rotation function but that moves the entire object around (0,0), I need the point in the middle stationary and at a non (0,0) point.

View 9 Replies (Posted: 03-02-2011, 07:08 PM)

Sponsored Links:

Related Forum Messages For Flash category:
ActionScript 2.0 :: Calculate The Direction And Speed A Circle Has After Colliding With A Static (non-moving) Circle?
I'm developing a game atm, and I need some help on the mathematics/coding of colliding circles (and their change in x/y speed). What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision

If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled. Does anyone here have any insight, links or tips on how I can du this?

Posted: March 8th, 2005

View 6 Replies!   View Related
Actionscript 3 :: Wait For Each Line Of Code In A Function To Be Executed Before Moving On To The Next Line?
I am trying to dispatch an event but not sure when I should do it to get the right results. The first event "submitClicked" is in the right spot and works great. However, the second event "dataReady" seems like it might be a problem. I need it to be dispatched after this.compiledFormData is set.Does AS3 wait for each line of code in a function to be executed before moving on to the next line?

// --------------------------------------------------------------------
public function submitForm()


Posted: Jun 29 11 at 22:10

View 2 Replies!   View Related
ActionScript 3.0 :: Circle Is Not Moving Smoothly?
I am trying to animate the circle to follow the cursor point. Its working fine, but when you move the cursor little faster the animation struck.

import;import fl.transitions.Tween;import fl.transitions.*;import fl.transitions.easing.*;
var moveXY:Number;var speed:Number = 1;


Posted: Jun 1, 2011 8:16 AM

View 8 Replies!   View Related
Flash :: Moving A Circle Around A Point?
I have a circle (bounding circle) offset from the centre point of my entity and I'm looking on how to move that circle around the entity as it rotates so that it's always in the same spot of the character.For example,say I have a bounding circle for the front of a car, when the car turns, that bounding circle needs to turn to So I have two points: position which is the position of the entity's centre point and offset which is the offset of the circle from that position. This assumes an angle of 0.

So if my car is facing 0 degrees: position (150, 150) and offset (50, 0) then the bounding circle would be at 200, 150.Now if I rotated the car 90 degrees, the bounding circle should be at position 150, 200.This is what I have now:

var differenceX : Number = _centre.x - _offset.x;
var differenceY : Number = _centre.y - _offset.y;
var rotatedX : Number = differenceX * Math.cos(_angle);[code]........But it's giving me these long ovals and now a perfect circle.

Posted: Aug 20 11 at 16:50

View 3 Replies!   View Related
IDE :: Number Of Images Moving Around Circle
Recently I came across a site showing a no. of images (probably 8 - 10) rotating around an invisible eclipse. When we put mouse-pointer over any of the images it's tip shows a linked site's name and if clicked that particular site opens up. Only one image is displayed perfectly which is on the top while rotating, while other remain blurred out not clickable. How to create such effect as I need to get it implemented.

Posted: February 28th, 2010

View 1 Replies!   View Related
ActionScript 3.0 :: Keep A Moving Object Inside A Circle?
I have a circle drawn on the screen, wherein I add a moving object. I want it to keep inside. My strategy is to calculate the circle's radius and compare it with the distance the moving object is off its center. I beleive it's the proper solution. However, I'm having a problem with letting Flash know when the running guy should stop, so he doesn't leave the circle and ruin all the fun. Here's the code I'm using (it's not working of course):

function moveTheCreaturesRightwards(event:Event)
if(maleMovingRight == true)


The line: rayMale.width = maleRadius.width; was added when nothing else had seemed to be working

Posted: 04-24-2010, 03:17 PM

View 3 Replies!   View Related
Flash CS5 - Moving Object Around In Circle One Degree At A Time
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; }
[Code] .....

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?

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

Posted: Aug 2 11 at 7:54

View 1 Replies!   View Related
ActionScript 2.0 :: Circle Stop Moving At Obstacle (Square)
I have a circle and a big square. The circle can be moved using the keyboard. I want the square to act as an obstacle, so the circle cannot be moved into it and the circle stops when it hits it, just like a if i were to try to walk into a building. Is there an easy way to do this?

Posted: 07-10-2009, 11:38 AM

View 7 Replies!   View Related
ActionScript 2.0 :: Circle MovieClips Moving Around Randomly On Stage
I want the final result to be a stage with a certain number of circle MC's moving around. I have made the circle MC, and added the AS so that it will start at a random point with a random color, then start moving around randomly. I want to make it so that In the beginning the document will duplicate the movie clip x amount of times, using a for loop. I want to then have all the new circles move around, and when two circles hit each other, they will dissappear, using the removeclip function. You can only use this on duplicated movieclips though, so how would i make all the circles duplicated? Is there a way to duplicate the original movieclip x amount of times then delete it? Or is there a way to remove the original after it is in a collision? Also I don't know how to do the collision detection. I am thinking of using a hittest, but would I just do it with a for loop? Is there a way so that if an MC hits any other MC?

Posted: August 6th, 2005

View 3 Replies!   View Related
ActionScript 3.0 :: Collisions Between Moving Circle And Rectangle Object
In AS3 is there an easy way for collisions to take place between a moving circle and a rectangle object. A moving circle has a direction and you need to know how it collides with an object rather than knowing it just hits. In .net you use a points test where you test several points around a circle to see what hits an object and then you can work out what direction it will bounce off.

Posted: October 9th, 2010

View 2 Replies!   View Related
ActionScript 3.0 :: Calculating X- And Y-pos On 'circle-line'?
This is actually more a math problem, but maybe some of you are better at math and have an idea on how I should be approaching this.

I'm dynamicly creating circles in my actionscript project and what I want now is calculate their x- and y-positions. I want them to be positioned in a circle, with the condition that it shouldn't matter how much circles I dinamicly load. (I'm having a hard time translating my problem to English, so I'll add an image so you instantly see my problem.) Does anybody have an idea on how to calculate this? What kind of formula should I use?

Posted: 11-08-2010, 05:35 PM

View 5 Replies!   View Related
ActionScript 2.0 :: Dynamically Moving An Object Along A Circle Motion Guide
I'm trying to move an object along circlular motion guide dynamically using two buttons -- a left button, when pressed down, will move the object counter clockwise, and the right button clockwise.

Posted: 07-05-2005, 06:13 PM

View 2 Replies!   View Related
ActionScript 2.0 :: Moving Circle To X Position When User Click On Square
I have a circle and a square on the stage. When you click on the square the circle will go to "circle._x = 300" when the circle is at 300 I want to make it when you click on the square the circle will go "circle._x = 45"

moveCircle = function () {
circle._x = 300;
if (circle._x >= 300) {
circle._x = 45;
}} square.onRelease = function() {
trace(circle._x + "is the position of the circle");

Posted: June 18th, 2008

View 5 Replies!   View Related
ActionScript 3.0 :: Draw A Line That Is A Radius Of A Circle?
I want to draw a circle on the scrren of a random x,y position and a random radius. Then, I would like to draw a line that starts at the center of the circle and ends at the spot where the circle ends, at its perimeter. All I have been capable of doing by myself was creating that circle and set the drawing position with the moveTo function to its center, but I don't know how to calculate the length of the radius, so I have the coordinates for the lineTo function.

Posted: 04-23-2010, 07:12 PM

View 7 Replies!   View Related
Actionscript 3 :: Box To Circle Collision - Continue Moving And Never Collide When Swapping Values Around
I'm trying to implement a aabb to circle collision.


Somehow the collision does work as expected. Either they never move at all and "collided" was traced, or they'll continue moving and never collide when I tried swapping values around. Is there something i'm missing in my logic??? My box-box and circle-circle collision are working fine.

Posted: Feb 24 at 5:13

View 2 Replies!   View Related
ActionScript 2.0 :: Straight Line Slowly Curving To C Circle?
I want a straight line to slowly curve so it become a circle. Can yo do that with actionscript?

Posted: February 7th, 2006

View 5 Replies!   View Related
ActionScript 3.0 :: Detect If A Circle Is Crossing A Diagonal Line?
Currently, I am using the code below. But it is telling me that the circle is starting to hit the line when it's y position is 40. But since the circle actually isn't crossing the line itself (virtually) until it's y position is at about 205, I don't want the trace-action called so early.

var circle: Sprite = new Sprite();;, 0, 10);
circle.x = 170;


Posted: April 6th, 2010

View 1 Replies!   View Related
ActionScript 2.0 :: Draw A Line / Circle And Place A Movie Clip On It?
I was wondering if anyone could tell me how and if it is possible to draw a line/ circle and place a movie clip on it and get the movie clip to go round the circle by placing the left and right arrow keys on the keyboard.

Posted: 08-06-2009, 12:00 AM

View 0 Replies!   View Related
Flash :: Draw A Line From A Point To Opposite Tangents On A Circle? Cone/wedge Shape?
This should be a bit of simple geometry: How do I calculate the points to draw the lines in the code below so that it makes a 2D cone or wedge shape?

import flash.geom.Point;

//draw circle
var mc=new Sprite()[code]...........

UPDATE:I should have mentioned my aim is not to draw a wedge shape, but to draw a line from a random point to the edge of an existing circle.If you're more comfortable with algebra than actionscript,

Posted: Apr 15 11 at 23:58

View 5 Replies!   View Related
Tween A Line That One End Is Moving And The Other Is Fixed?
i wanna do the shape tween or should i say tween a end of the line should stay still while the other should expand and contract moving on a designated its not just an shape tween where line will expand..i want the moving end to go along some path.

Posted: 03-02-2012, 07:16 AM

View 14 Replies!   View Related
ActionScript 3.0 :: Draw A Line That Keeps Moving Using Just It?
I'm trying to draw a line that just keeps moving using just AS3. Like when a heart beat monitor flat lines. The reason is I'm adding this to arduino project so when you breath into an alcohol sensor the line will move up if you have been drinking. I just want to be put on the right path.

Posted: 02-22-2011, 03:48 PM

View 1 Replies!   View Related
ActionScript 2.0 :: Moving A Line Like A Flag?
you know when a flag waves? the movement of an eel? a sperm tail?

that is what i am trying to accomplish. that movement.

other than very rough tweening i am not getting close.

Posted: July 2nd, 2003

View 4 Replies!   View Related
ActionScript 3.0 :: Moving Objects In A Straight Line?
I have this code inside an ENTER_FRAME event. I'm trying to move the "ball" from its x- and y-position to a tartget x- and y- position:

if (processClick)
if (ball.x < targetX) ball.x += 8;
if (ball.x > targetX) ball.x -= 8;


But the "ball" doesn't move in a straight line, I think it is because the x- and y-movements are processed independently?

Is there a way thay I can make the "ball" move in a straight line from the starting point to the target point?

Also, is there maybe a way to manually create a tween between the starting point and the target point using actionscript? If I export the "ball" movieclip for actionscript?

Posted: 06-22-2009, 01:22 PM

View 4 Replies!   View Related
ActionScript 3.0 :: Draw A Line Following A Moving Point?
I have a motion tween right now with a moving point that is following a copied and pasted motion path. Is there a quick way to have the point draw a line behind it as it moves along the motion path??? I can't seem to find a good way to do it in AS3.

Posted: 04-12-2011, 10:53 AM

View 1 Replies!   View Related
Copyright 2005-08, All rights reserved