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: 03022011, 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 (nonmoving) 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 (nonmoving) 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 circlepoints (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.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 flash.events.MouseEvent;import fl.transitions.Tween;import fl.transitions.*;import fl.transitions.easing.*; var moveXY:Number;var speed:Number = 1; [Code].....
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 mousepointer 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) { [Code].... The line: rayMale.width = maleRadius.width; was added when nothing else had seemed to be working
Posted: 04242010, 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 readonly 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 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 Ypos On 'circleline'?
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 ypositions. 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: 11082010, 05:35 PM
View 5 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" Code: moveCircle = function () { circle._x = 300; if (circle._x >= 300) { circle._x = 45; }} square.onRelease = function() { moveCircle(); 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: 04232010, 07:12 PM
View 7 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 traceaction called so early. Code: var circle: Sprite = new Sprite(); circle.graphics.beginFill(0xFF0000); circle.graphics.drawCircle(0, 0, 10); circle.x = 170; [code]....
Posted: April 6th, 2010
View 1 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
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 yposition to a tartget x and y position: Code: if (processClick) { if (ball.x < targetX) ball.x += 8; if (ball.x > targetX) ball.x = 8; [Code].... But the "ball" doesn't move in a straight line, I think it is because the x and ymovements 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: 06222009, 01:22 PM
View 4 Replies!
View Related
