Actionscript 3 :: Rotating A Sprite Around Its Center Point?

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


Similar Posts:


IDE :: Images Rotating Around Center Point?

Dec 10, 2009

how to do an effect like the one seen on this page?: http:[url]....

View 1 Replies

ActionScript 3.0 :: Rotating Point Around Center Of Circle

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

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

Flash :: Rotating Sprite Moves The Sprite From It's Original Location

Jul 6, 2011

I'm doing a simple rotation on a sprite but there's a weird behavior where the sprite does not rotate around it's top left. I think I'm rotating along the top left of the test class instead of the sprite child. I would like to rotate the rectangle around it's top left corner (kinda like a clock hand). The code is pretty short so I'll let the code + pictures explain my problem:

package
{
import flash.display.Sprite;

[Code]....

I've read a lot of stuff about rotating around a fixed point, I've tried doing it with movieclips instead of sprites, I even copy pasted a tutorial on rotation and nothing works.

View 3 Replies

ActionScript 3.0 :: Finding A Point Relative To A Center Point?

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

ActionScript 2.0 :: Rotating Mc In Its Center?

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

ActionScript 3.0 :: Rotating Circle From Center With Mouse/

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

ActionScript 3.0 :: Rotating Objects To Face Center?

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

ActionScript 3.0 :: Rotating A MovieClip Around Its Center Using A Handle?

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

ActionScript 2.0 :: Rotating A Loaded Movie In The Center?

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

ActionScript 2.0 :: Rotating Dynamically Fed Photo Around A Center?

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

ActionScript 3.0 :: Add Textfield To Rotating Sprite?

Jun 20, 2010

I am using a class to create a sprite of a ball that is rotating it's parent. Both the parent and the child are adding a textfield child which indicates the radius. For some reason the textfield on the outer ball is falling behind the sprite, so only visible if mousing over it. Also the text is not rotating relative to the ball. It stays vertical.[code]...

View 5 Replies

As3 :: Flash - Rotating Image And Then Moving X And Y Relative To Center?

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

Actionscript 3.0 :: Dynamically Generated Objects Rotating Around Its Own Center?

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

ActionScript 2.0 :: Pausing MovieClips Rotating Around Center Axis

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

ActionScript 2.0 :: Rotating Around Point?

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

ActionScript 3.0 :: Rotating A 3d Point Around A 3D Line?

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

ActionScript 1/2 :: Rotating A Movieclip In A Given X,y Point?

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

ActionScript 2.0 :: Stop Rotating Around A Common Center When The Mouse Leaves The Stage?

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

ActionScript 3.0 :: Off-center Rotation Of A Sprite?

Aug 19, 2010

As is well demonstrated by a Google search, the rotationX, rotationY, and rotationZ properties turn a display object around the center.

That's all well and good, but I want to rotate a display object about a different point.

I can't believe there isn't a way to do this, but I don't see anything that addresses this question specifically.

View 3 Replies

Actionscript 3 :: Track A Point On Rotating MovieClip?

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

ActionScript 2.0 :: Rotating Object To Point Forward?

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

ActionScript 2.0 :: Rotating Group Of Squares Around Point?

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

ActionScript 3.0 :: Rotating MovieClip To Point At Mouse

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

ActionScript 3.0 :: Rotating A Circle To A Specific Point

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

ActionScript 3.0 :: Align Center A Sprite In Its Stage?

Jul 8, 2009

I try to align center a sprite container in the center of the stage.

What can be the method to do it?[code]...

View 5 Replies

Actionscript 3 :: Sprite Rotation Around Center Error

Jul 6, 2011

I found this actionscript online to rotate a sprite around its center point but I get two errors when I use it. 1084: Syntax error: expecting identifier before leftparen. 1084: Syntax error: expecting rightparen before leftbrace. Also, in place of angleDegrees do I put in the angle I want the sprite to rotate by?

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) {
var m:Matrix=ob.transform.matrix;
m.tx -= point.x;

[Code]...

View 1 Replies

ActionScript 3.0 :: Rotating A Circular Set Of Links To A Specified Point/Angle?

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

ActionScript 3.0 :: Rotating Around Matrix Point To Specific Angle

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







Copyrights 2005-15 www.BigResource.com, All rights reserved