ActionScript 3.0 :: Rotating Around Center Point While Updating .x & .y Properties?
May 27, 2010
I want to be able to rotate the ship around the center point and be able to update the .x and .y at the same time.I've got this two versions of code.1
Code:
if (aKeyPress[38])
{
[code].....
View 2 Replies
Similar Posts:
Dec 10, 2009
how to do an effect like the one seen on this page?: http:[url]....
View 1 Replies
Aug 9, 2011
I searched online and found this script that is supposed to rotate and image but I'm not sure how to use, where to put in the degree angle that I want my sprites to rotate by. Also, I get an error. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace.
var point:Point=new Point(spr_box.x+spr_box.width/2, spr_box.y+spr_box.height/2);
rotateAroundCenter(spr_box,45);
function rotateAroundCenter (ob:*, angleDegrees) {
[Cde].....
View 1 Replies
Mar 9, 2009
I am trying to rotate some points around the center of the circle(0,0), however I'm getting weird values from the output. I've commented the problem code..
Code:
var r:Number = 10;//radius
var y:Number;
var x:Number;
var a:Number = 90;//angle of which the semi-circle is facing.. could be a random angle.
var ax:Number;//rotated points
[Code] .....
I am using the semicircle in BitmapData collision checking with getPixel(), with a moving circle...
View 1 Replies
Nov 9, 2010
I'm trying to figure out how to find a point relative to the center of an object, modified by its rotation. For example, in the attached swf, I've been messing around trying to draw trails to a bitmap, coming out of the thrusters. I didn't have a problem at first, but as the ship rotated, the lines that were being drawn wouldn't remain relative.
http:[url]....
I'm sure this is because I have no idea what I'm doing, and I've just been sort of idioting my way through it. That aside, is there an easy way to find the point I'm looking for? For instance, say I want a point at Y -14 of my ship, but I want that to remain relative to the ship as it rotates.
View 14 Replies
Feb 16, 2011
I'm making a modular site, that loads in external swfs that need to have decent screen reader names for each of the buttons.
The shell swf is set up to work with Thunder and NVDA screen readers by creating an AccessiblityProperties instance and assigning it to the relevent display objects then calling Accessibility.updateProperties( ) ; This method works in the main swf, but when used in the loaded swf it's not picking up the updated accessibility properties of the buttons, even though Accessibiltiyy.updateProperties( ) ; as been called again.
View 1 Replies
Jan 15, 2010
I'm updating the x and y properties of my Model.as when I drag a Sprite around the stage. However, because both setter functions dispatch an Event.CHANGE, the property that is updated second seems to get locked in place (meaning it doesn't seem to be updated with the correct value as it locks the Sprite in a horizontal or vertical line of movement).
snippet from BubbleController.as
ActionScript Code:
private function onViewMouseDown(me:MouseEvent):void
{
[code]....
View 0 Replies
Feb 18, 2003
my problem is that even if the registration point of the MC I want to rotate is in its center it keeps rotating in its upper left corn.The MC is a jpg I load dynamically.The syntax I use is : _root.photo._rotation += 90;
View 14 Replies
Jan 31, 2010
I have been working on this and thinking about it for days but I just can't seem to get it right. I want to have a circle that I can "pick up" with the mouse and then rotate (with the rotation point in the center). Currently I have done this with the following code:
PHP Code:
var radians = Math.atan2(mouseY-circle.y, mouseX-circle.x);
var degrees = Math.round((radians*180/Math.PI));
circle.rotation = degrees + 90;
I have added a mouse listener for movement to the circle mc and then checked if a button was down. On button down this code would be executed on enter frame. This code works but the main problem is that I want to be able to "pick the circle up" at any angle and rotate it. If I pick it up with this code the circle automatically rotates to 90 degrees.
View 1 Replies
Dec 14, 2009
All I need to do is rotate an object (which could spawn at any point along each of the four edges of the screen) so that it faces towards the centre of the screen. Obviously this will be done using the .rotationZ property. I will know the starting point of the object, and the centre point of the screen (400, 300). The object begins facing directly 'up' (e.g. if it spawned directly below the centre of the screen it would already be at the correct angle).
View 2 Replies
Nov 4, 2010
a movieClip that contains a polygon and some circles at the angles of the polygon. I want to use the circles as rotation handles.Now the code below works but it terribly, terribly slow.I've seen a couple of other examples of rotation using the mouse position, but I want the polygon to rotate via the handle; I think that means the angle of rotation needs to be updated each time the mouse moves.Is there a cleaner/more efficient way to do this?Also, this works only for one direction right now no matter the x/y direction you move the mouse.
public function mouseDownRotate(event:MouseEvent):void {
// get the global x and y of the dragged piece (offset so it looks like it's rotating around the polygon's center
[code]......
View 6 Replies
Jan 27, 2006
I have spent hours trying to figure out how i could rotate a loaded movie through the centre axis rather than the set point set by flash in the left corner.
View 1 Replies
Sep 6, 2006
I'm doing a little photo rotation front-end for a site I'm working on. It's a custom photo gallery site that needs to have a photo rotation functionality to it. The back-end developers couldn't find a decent way to do it in Javascript, so they've come to me to figure it out in Flash.They pointed me to the Flickr rotation tool as an example. Seems like it should be straightforward:Load photo into empty movie clip on stageRe-center photo movie clip to the stageUse left/right rotation buttons to rotate image in 90 degree incrementsThat said, I'm having a tough time, after I load a photo into the empty movieclip, using a rotate left and rotate right button to spin the photo around. Obviously, the registration point is in top-left corner of the photo movieclip when the photo is loaded.
I've read that rotation can be managed by putting the clip to be rotated into an outer clip, but...there's a catch......I won't ever know what the exact size of the photo being loaded is going to be, so I can't set the outer clip to a certain size. I only know that it will never be wider than 100px.
View 3 Replies
Feb 21, 2011
I am in the midst of finishing up a design application where you can upload images and colors. I use the greensock transform manager. I am taking anything a user does and recording it so I can recreate what they made on larger scale behind the scenes (to be exported for printing purposes)
The problem I am running into is with rotation and moving x and y values. The transform manager does everything relative to a center point, but when i recreate the image object the registration point is at the top left. I have found how to rotate around the center of the object using the transform matrix, but I can't seem to move the x and y correctly because these values change when you rotate. I want to just move the image to the left or right relative to the center. How could I go about doing this.
Here is how I rotate.
private function rotateAroundCenter (ob:*, angleDegrees:Number, ptRotationPoint:Point) {
var m:Matrix=ob.transform.matrix;
m.tx -= ptRotationPoint.x;
[Code]....
View 1 Replies
May 12, 2009
i have a triangle that i generate using the following code:
Code: Select allinternal function generateTriangle(w, h, topPoint, color = "0xFF9900") {
var triangle:MovieClip = new MovieClip();
with (triangle.graphics) {
[Code]....
I use this function and a foreach loop to generate 9 differently colored and sized triangles, which works fine when i place them on the canvas. But if i try to rotate them they rotate around the 0,0 point - i want them to rotate around the center of the individual triangles, how do i do that?
1. How do i move a dynamically generated triangle inside a movieclip? Solved using [URL]
2. How do i access each of the triangles inside the movieclip, or even better, place them in 9 different movieclips using addChild so that i can move them around individually?
View 4 Replies
Nov 30, 2009
I have 4 movie clips rotating around a center axis. I know how to make each one pause individually, but I don't know how to get them all to pause when you roll over just one of them. Right now it only pauses the one you roll over and the others continue to rotate. I have this code pasted into the actions of each movieclip that is rotating.
Code:
onClipEvent (load) {
var radius = 220;
var speed = .6;
var xcenter = 450;
var ycenter = 300;
[Code] .....
View 1 Replies
Jul 26, 2006
concept I can't wrap my mind around.If you've been the the sitehe has a "picture map"I've seen this used at other sites too.But what the rotation. The pictures always rotate around the point you click on.I just don't get it. I understand the momentum and all for the swing though
View 1 Replies
Jul 2, 2011
Line is defined by two 3d points; (0,0,0) and (x,y,z). And there is also this 3d point. How can rotate this 3d point around the line?
Something like this (points indicate vectors in my expression, it's the same thing) :
I found some stuff on the internet but I couldn't really figure it out.
View 6 Replies
Dec 8, 2010
how can I make the green movieclip rotate in the point that the claw has catch it. To give an impression of physics. Here´s the image, to give you an idea:
The point (x,y) that the claw catches the colored movieclips below is not unique it can be any number. As long as the claw catches the colored movieclip.
View 13 Replies
May 4, 2010
[URL]I'm using this code and I made some changes like freezing the rotation when the mouse is over the rotation entities. But I'd like to stop rotation when the mouse leaves the stage. How can I do?This is my code
Code:
import flash.filters.BlurFilter;
import mx.transitions.Tween;
import mx.transitions.easing.*;
[code]....
View 2 Replies
Feb 14, 2012
I have a MovieClip, that is representing a character in my game. Id like to "create bullets" shooting out from the tip of my characters gun. Problem is that when my character turns around, also the point rotates around the MovieClips pivot.
Is it possible to anyhow easily track this point, so that I could dynamically create new objects at the same location.
I tried to add a new MC as a child to my character, with the initial position at the guntip. In some systems child-objects "follow" their parents around, but it didnt seem to work here.
Is there any other "native" way of doing this, or do I just have to have a Polar-coordinates representation of the point relative to character-MovieClips origin, and add the MC rotation to theta, so that I can calculate the X and Y coordinates?
View 2 Replies
Jun 14, 2005
I'm working on creating an animation in which there are insects randomly moving around - based on tutorials on this site. Does anybody know how to make the insect rotate so that it always points towards the direction of travel.here's what's on my movie clip:
Code:
onClipEvent (load) {
scale = (random(100)+50);
this._alpha = random(50)+20;
this._xscale = scale;
[code]....
View 5 Replies
Feb 22, 2007
I'm actually coding this in Java (with which I have just a few days experience), but as far as the logic goes, I thought this would still be an appropriate place. I'm making a Tetris-eque game and having trouble with rotation. Each shape (rectangle, L, "step", etc) consists of 4 or 5 smaller squares (image below), and I want to be able to rotate the pattern of squares 0, 90, 180 and 270 degrees around a designated point.
x = originX + cos(angle) * radius;
y = originY + sin(angle) * radius;
I thought I understood these, but apparently not, since I can't seem to get it working� For each shape, I would declare the x, y coordinates for each of its smaller squares, relative to one another. Then, I'd send these values to a function that should take the pattern and rotate it according to the specified angle. In Java (to the best of my knowledge), the upper-left is always the "registration point" for graphics. So, I set the relative coordinates for the squares of each shape such that the left side of the leftmost square is at x = 0 and the top side of the uppermost square is at y = 0. Here's an example, the shape of a plus sign (+).
Code:
//top-center
x = squareWidth;
y = 0;
[code]....
no rotation (just the shapes)and this is what happens when I implement the rotation adjustment.
View 7 Replies
Jul 4, 2007
I am trying to make a line point to wherever the cursor is when I stumbled upon the Math.atan2(); function. It appeared that i would put
line.rotation = Math.atan2(1,1);
to get 45 degrees or pi/4, but I was wrong. It barely moved the movieclip at all. So what I'm trying to do is to get this movie clip to rotate along with the mouse so the line is always pointing at the cursor. Also, how would you get movieclip to move along the line created by the line of these two points?
View 9 Replies
Mar 6, 2009
What I'm trying to do is make a dial-type of interface, where you click on a point on the edge of a circle and that point will rotate to another point at the top of the circle. What I can't figure out is how the make "Point B" rotate to "Point A", where "Point A" is always fixed at the top of the circle and "Point B" (and Point C and Point D, etc...) are located along different points on the edge of the circle. I'm using the tween function to rotate, so what I need to figure out is how to get the difference in the rotation between the two points.
View 7 Replies
Jan 27, 2010
I have a set of links (movie clips) arranged in a circle. When one of the links is clicked, I would like the circle of links to rotate until the selected link is in a certain position - straight down (90 degrees) in this case - and the others to maintain their positions relative to the clicked link (ie: they all move, but the distance between them is maintained). The behavior is intended to be like a bullet rotating into a chamber on a revolver, or - more accurately - like that of a Ferris Wheel. [URL] Here is my mangled version of the AS from the site linked above:
ActionScript Code:
// setting variables
var centerX = Stage.width/2; // Stage Center X
var centerY = Stage.height/2; // Stage Center Y
[code]....
View 7 Replies
Mar 5, 2010
I have a slider which I want to use to rotate an image around it's center. This normally is easy but my problem is the clip is made dynamically and the size changes so I can't use the default registration point and I need to assign the center point before I rotate it. I found the rotateAroundExternalPoint function which rotates around a center point fine. How to get it to rotate to a certain angle and then have it stop at that angle. The rotateAroundExternalPoint increments the rotation rather then allowing me to set the angle to rotate to. Is there anyway that I can set what angle to rotate my clip to? It right now increments the rotation by the x coordinate of my slider bar (slider_position.x).
Code:
import flash.geom.Matrix;
import fl.motion.*;
var mat:Matrix = clip.transform.matrix;
addEventListener(Event.ENTER_FRAME,EnterFrame3);
function EnterFrame3(event:Event) {
var center_point_x = clip.height / 2
var center_point_y = clip.width / 2 //
MatrixTransformer.rotateAroundExternalPoint(mat,center_point_x,center_point_y,slider_position.x);
clip.transform.matrix = mat;
}
View 9 Replies
May 2, 2010
I've been trying to figure this out for a while now and cannot get it to work. I have a movieclip that can be moved up, down, left and right with the arrow keys, and reflected/flipped using the arrow and control keys together. However, I want to be able to use the arrow keys and shift to rotate the movieclip about a point with x co-ordinate 230 and y co-ordinate 180, regardless as to whether or not the movie clip has been moved up, left, etc.I've tried several different codes based on examples I've found online, but none have worked. I cannot make sure the centre point of rotation never changes.
View 0 Replies
Mar 25, 2007
How to make a point rotate about the circumference of a circle upon dragging. How do I go about doing it? Is there something to do with the
startDrag(...); ?
From what I have right now, I can move the point but not on the circumference of the circle.
View 3 Replies
Oct 20, 2009
I have a dynamic image loading into a movie clip and i dynamically created a transform box around it. However the anchor point of that transform box is coming on the left top instead of in the center, which is not letting the image transform properly. how to dynamically put the anchor point to center through AS2?
View 1 Replies