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


Similar Posts:


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 :: Rotation Center Is In Left Of The Image - Aren't 3D Rotation From Transform Panel

Jan 7, 2010

I have a movieclip and when I do 3D rotation from Transform panel, It rotates perfect, center is in the middle of image, and when I apply mc.rotationY, rotation center is in left of the image, aren't 3D rotation from Transform panel and mc.rotationY from AS same? what's up?

View 2 Replies

ActionScript 3.0 :: How To Center A Rotation

Jul 13, 2008

As you can see in my code, I'm trying to adjust on the fly the x and y properties so that the movieclip gives the impression to rotate from its center and not from its corner at 0,0

Code:
var myclip:MovieClip = new MovieClip();
myclip.buttonMode = true;
myclip.graphics.beginFill(0);

[code]....

but it doesn't work and the clip does not rotate well

View 5 Replies

AS3 :: Flex - How To Do 3D Rotation Around Center Using Matrix3D

Dec 14, 2009

I am trying to rotate a Sprite in three dimensions around its centerpoint, and I am struggling to understand some of the behavior of matrix3D.

Ive overridden the set rotationX, rotationY, and rotationZ methods of the Sprite as follows:

override public function set rotationX (_rotationX:Number) : void {
this.transform.matrix3D.prependTranslation(this.width/2.0, this.height/2.0, 0);
this.transform.matrix3D.prependRotation(-this.rotationX, Vector3D.X_AXIS);

[Code].....

I am using prependTranslation to correct the centerpoint of the rotation, and the first prependRotation to cancel out any previously-applied rotation.

Testing it out, rotationX works exactly as expected, and the Sprite rotates around its horizontal axis.

rotationY and rotationZ also appear to work fine. However, there is one problem: whenever rotationY or rotationZ are set, all of the other rotation values change as well. This is not a problem with rotationX -- if I set rotationX, nothing else changes. But if I set rotationY or rotationZ all the rotation values change, which is a problem for my app (which is trying to save and restore values).

I think I am just lacking some understanding about what is going on with matrix3D. How can I implement this so there is no interdependence between the values?

View 2 Replies

ActionScript 3.0 :: Set Rotation Center Point?

Jul 9, 2010

I am new in action script 3... i am not able to rotate movie clip from center point(movile clip is a containear holding many clips).

View 9 Replies

Flash :: Change Center Of Rotation Box2d?

Feb 13, 2011

I have a b2PolygonShape body and apply a force to it.

_recbody->ApplyForce( b2Vec2(6.0, -6.0), _recbody->GetWorldCenter() );

I want to change the centre of rotation of the body to be more in the front of the body. So that applyForce and also collisions make the body not turn in the centre but more in the front.

View 2 Replies

ActionScript 3.0 :: Rotation Around Center With Registration In Top Left

Jun 20, 2011

I coded an entire file based on the top left registration point of my movie clip. I want it rotate it to point at the cursor, but since the registration point isn't in the middle.. its not a perfect rotation around the center of the mc. Is there anyway to rotate it around the center of the movie clip without changing the registration point?

ActionScript Code:
stage.addEventListener(Event.ENTER_FRAME, aimBall, false, 0, true);
function aimBall(event:Event):void {
ball_mc.rotation = getAngle(ball_mc.x, ball_mc.y, mouseX, mouseY) -90;
trace(ball_mc.rotation);
} function getAngle(x1:Number, y1:Number, x2:Number, y2:Number):Number {
var radians:Number = Math.atan2(y1-y2, x1-x2);
return rad2deg(radians);
} function rad2deg(rad:Number):Number {
return rad * (180/Math.PI);
}

View 9 Replies

ActionScript 2.0 :: Rotation Around Common Center OnEnterFrame

Mar 25, 2008

url...I'm using this code i made some changes like changing the array for a xml.In some part i put a button to stop the movement and i used [code]
and it works perfectly, but then i want to return with another button to the movement. and i can't make it work.

View 2 Replies

ActionScript 3.0 :: Having A Fixed 3d Rotation Center For A Movieclip?

Feb 5, 2011

Is it possible that I can have a fixed 3d rotation center for a movieclip.So if I have two movieclips spaced apart and I have rotated them, they rotate in their own axis rather than based on a single axis.

View 6 Replies

ActionScript 3.0 :: Make Shape Rotation At It's Center Point?

Jun 14, 2011

I draw a shape,like follows:

var shape1:Shape;
shape1=draw();
addChild(shape1);
shape1.rotation=50;

[Code]....

Then I want to rotate the shape at it's center point(200,202) by using shape1.rotation=50,but I find the shape don't rotate at the the center of it's shape. How to realize the function which make shape rotate at its center point?

View 4 Replies

ActionScript 3.0 :: Change The Rotation Point Of A Sprite?

Feb 4, 2008

I'm attempting to write a racing game. I've loaded in my image, I brought it to the stage and now, all I want to do is rotate it from its' center and not upper left corner.

The code:

racer.rotation += 5;

rotates from the upper left corner. How do I rotate from the center of the car/sprite? I've tried putting it into a container but I'm unsure on the coordinates of the container because I tried to set the x,y coordinates to half the sprite image but y'know, it's not doing what I expect it to.

ActionScript Code:
if (arrowLeft) {
var container:Sprite = new Sprite();

[Code]....

I will never sneer at another racing game! I didn't think it would be this hard to do a simple rotate of an image!

View 3 Replies

Actionscript 3 :: Applying Rotation Of Sprite To StartDrag()'s Rectangle Bounds

Apr 13, 2010

from my main class i call to create a sprite and add it to the stage

private function addSwatch(evt:MouseEvent):void
{
if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
{

[Code]....

View 1 Replies

Flex :: Converting Sprite To Bitmapdata With A Different Registration Point And Rotation

May 22, 2011

I'm trying to convert a Sprite that I have into BitmapData so I can perform some collision detection. There are a few things about the way the Sprites are used that is making this more difficult than I expected:

The Sprite itself is a container which holds another Sprite that actually has a box drawn in it. The inner Sprite is positioned negative half its width & height so that it can be rotated from the center via the container. The container may be rotated at any angle at any given time

So my approach thus far has been attempting to draw the outer Sprite onto a new BitmapData object with a Matrix to account for the difference. Whilst I can use a Matrix to make this work for one particular rotation angle, I cannot find a way to make it work for any rotation.

Here's what I'm doing to draw onto the new BitmapData:

var p:Product = getProduct(); // Product is the container with the inner sprite
var bounds:Rectangle = p.getBounds(stage);
var bd:BitmapData = new BitmapData(bounds.width, bounds.height, true, 0x00FFFFFF);

[Code]....

Translating by the same amount as the previous example will no longer work here, and the box will still be cut off. I've looked around at some solutions posted before or suggestions from other people but they don't seem to work for me due to my container Sprite and rotation.

View 1 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 :: 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

ActionScript 3.0 :: Spread Items In A Circular Path With A Right Rotation Angle Facing The Center?

May 29, 2011

I am trying to place leaves in a circle to create a flower with code. I run into some problems.Is it possible to rotate the leaves so they all rotate in the direction of the center of the flower?  And is it possible to calculate how many leaves can fit around a certain circle radius without to much overlapping?

View 1 Replies

ActionScript 3.0 :: FP9/10 Enforces A Minimum Increment Or Resolution For The Sprite Rotation Property?

Aug 18, 2009

Does anyone know if AS3 or FP9/10 enforces a minimum increment or resolution for the Sprite rotation property?It seems to only allow rotations in multiples of 0.25 degrees.For example:

var lines:Array = new Array();
for (i=0; i<2000; i++){
lines[i] = new Shape();
lines[i].graphics.lineStyle(.1, 0x000000);

[code]...

This draws the lines in groups at 0.25 degree spacing with gaps between them.

View 2 Replies

ActionScript 3.0 :: Sprite X / Y - Values Reference Top Left Corner Or Center

Jun 3, 2010

I've checked this behaviour: If I define a sprite (by programming) as:
var square:Sprite = new Sprite();
square.graphics.beginFill(16750899, 1);
square.graphics.drawRect(0, 0, width, height);
square.graphics.endFill();
return square;
When I check the position of the sprite ( square.x, square.y), they reference the TOP-LEFT CORNER.

If I create a symbol by Flash CS4 and export to Actionscript (I also associate one class which extends Sprite for doing "new()" in my code):
var square: MyClassExtendsSprite = new MyClassExtendsSprite();
When I check the position of the sprite (x, y), they reference the CENTRE of the sprite!

View 3 Replies

Actionscript 3 :: Augmented Reality Flartoolkit Rotation - Trace The Rotation Of The Marker

Mar 23, 2011

I'm trying to do some augmented reality projects with flartoolkit . I can now put simple 3d objects on my marker and it works fine , but I wanna give my project some events that the user can interact with. I'm trying to trace the rotation of the marker. there's a container:DisplayObject3D which my application uses to add the 3d objects , I traced this :"trace(container.rotationZ)" but it's just returning 0 . I studied another AR application's source code and it was using the rotation of it's container object without problem .and I think I should mention that I'm using the exercise file of seb lee delisle papervision3d course from [URL]. anyone has any experience with flartoolkit? the main functions of my my code is as below:

[Code]...

View 1 Replies

ActionScript 3.0 :: 3D Rotation Of Nested Movieclips, Separate Of Parent Rotation?

Aug 11, 2010

Is it possible to have the child movieclip rotate separate of the  rotation  properties assigned to the parent? so ultimately giving the  child  element it's own axis?I've customized Lee Brimelows (gotoandlearn.com) 3D carousel to spin  on  the x axis to make it a vertical carousel. I've also rotated that by 45 degrees on the y axis to see all the items, and wrote a snippet of   code to hide the left portion of the carousel. The entire  carousel is contained within the 'container' movieclip, and  inside of  that are my carousel items (as seen below), with the larger  item being  the item in focus.

On rollover of the item in focus, I want to rotate it so it faces the   viewer (as seen below),basically removing the 45 degree rotation   applied to the container.The problem i'm running into is when you rotate the container (changing   the rotationX of the container), the axis basically rotates with it, so   when i rollover the next item 'in focus', the following happens..(in  the  example where it appears how it want it to, the carousel is at a   rotationX of 0, so it works fine)

View 2 Replies

ActionScript 1/2 :: Inconsistent Rotation - 270 Degrees Of Rotation Disappear?

Apr 21, 2009

Program A has a cannon that aims to line up with where-ever the mouse is pointing, in 360 degrees, and fires when the mouse is is clicked. Program B has an eye instead of a cannon that should in theory do similar functions when the capslock key is toggled, but instead only has a 90 degree range of motion from the Right of the eye toward the bottom (quadrant 4 only). Where did the ther 270 degrees of rotation disappear to?

[Code]...

View 4 Replies

ActionScript 2.0 :: Create A 3d Rotation Much Like The Widely Used Carousel Only The Rotation?

Aug 11, 2006

i.m trying to create a 3d rotation much like the widely used carousel only the rotation i desire consist of four upright(90 degrees) movieclips resting on a slanted, 30 degree plane which rotate onEnterFrame or following a tween on a oval like path - then pause for a given number of seconds at the four movieclips positions equal in distance on the plane

function around() {
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var s = this._y /(centerY+radiusY);

[code]....

View 7 Replies

IDE :: Z - Rotation X And Rotation Y Missing In Motion Editor Panel

Feb 23, 2009

Why isn't there the Z, rotation X and rotation Y fields in my motion editor panel?

View 1 Replies

ActionScript 3.0 :: Scaling And Get The Center Window To Stay In The Center Of The Web Browser Screen

Aug 15, 2009

I have a center window and a background in my flash file. I am trying to get the center window to stay in the center of the web browser screen and get the background to expand and fill the entire web browser screen below center window layer. Sort of like this site [URL] I've currently converted the background to a movie clip and have this code.

[Code]....

View 11 Replies

Keep Center Of The Movie In The Center Of The Scree Regardless Of Browser Size?

Mar 23, 2009

My flash movie is 1440x900 but the area where all the important stuff happens in within 1024x768, i am trying to keep the middle in the center regardless of browers size or aspect ratio.

I can center the page but it doesn't work as i need it to. If the browers is small (1024x768) the swf is justified against the left edge, but not keeping the middle in the middle of the brower.

[URL] is an example of exactly what i am trying to achieve.

View 13 Replies

Actionscript 3.0 :: Rotation X Rotation Y Don't Show?

Oct 8, 2009

I am watching the tutorial on the motion editor and when he opens the motion editor to edit the Rotation X and Rotation Y values I'm in trouble.My motion editor now only shows Rotation Z but, no Rotation X or Rotation Y. What am I doing wrong?

View 1 Replies

Actionscript 3 :: Class Extending Sprite - Set The Sprite's Width And Height Properties?

Mar 5, 2010

I created a class, extended the sprite class, and now in the constructor I am trying to set the Sprite's width and height properties which are inherited from the DisplayObject. However, after I set this.width and this.height, and print the values, I get 0 for both.

What the heck is going on? When I view the livedocs I see that DisplayObject has width and height listed as public properties. I have been able to instantiate a Sprite directly, and set the width and height after it's been instantiated, so I don't get it.

package {
import flash.display.*;
public class ScrollBar extends Sprite {[code].....

View 1 Replies

Flash: `sprite.visible = False` Doesn't Hide Sprite Immediately?

Apr 4, 2011

I've got a sprite which I want to temporarily hide... But changing the .visible property doesn't do what I expect. The code looks roughly like this:

[Code]...

View 1 Replies

IDE :: Adding A Single Sprite On Main Moviclip Sprite Remains Invisible

Mar 2, 2009

I created a new AS3 document (550px by 400px) and added the following code to the first frame.

However, when I run this, I see nothing painted on the screen at all, the screen remains completely white.[code]...

View 3 Replies







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