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


Similar Posts:


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 :: Rotating To Face Something

Oct 13, 2004

is it possible to rotate an object so that it always faces another object that is able to move around the screen? as in track it on the y and x axis?

View 2 Replies

Actionscript 3 :: Adobe Flash Cs4 - Object Rotating To Face Another Object

Jun 30, 2011

i am currently having trouble with my object rotating to face another object.currently it works fine as in this picture, my object at the origin will be able to rotate and move to the object in the 3 quadrants except the quadrant with positive 90degrees to 180 degrees, my object will rotate a few full rotation for some time while moving to the object does anyone know why? the sentence that i use to rotate is rotation += (foodLocationDegrees - (rotation - 90)) * .2; whereby food is calculated using

[Code]...

View 1 Replies

Flash :: Rotating Object To Face Another Object?

Jun 28, 2011

currently i have a function in which my object fish will move to a food i am having trouble getting it to rotate nicely to the food currently my function is as below.if the food is above the fish my fish rotation is 0 which is facing up, if the food is below my fish i will give it a rotation of 180 which will make it face down , however the rotation is too sudden it does not give a nice and realistic effect of rotating to the food.how can i make it when rotating to move some distance and at the same time rotate? because it cant rotate to the food in the same spot as it would not be realistic.

public function moveToFood():void
{
var foodTarget:Food = fishArray[fishArray.length - 1];

[code]......

View 5 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

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

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 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 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

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

Classic Tweens Not Rotating Objects

Jul 25, 2011

So I just started using Flash CS4 from Flash 8, and I like it so far, but there's on major problem: the "classic tweens" (motion tweens) aren't rotating some of the objects I have. Like there's this flame thrower I drew, and I rotate it at the end of the motion tween, but it doesn't rotate. It will just wait till the last frame and then it will show the rotated frame. Motion works in the motion tweens, but not enlarging or rotating... why? It seems more like a glitch, because sometimes I make a classic tween and it rotates stuff just fine, but sometimes it just doesn't... what am I doing wrong here? What's going on?

View 3 Replies

ActionScript 3.0 :: Reassigning Z Value To Rotating Objects?

Feb 21, 2009

I need to reassign z value to some objects that are rotating in 3d. (see attachment).

This is my code: but it doesn't work:

ActionScript Code:
for (var i:uint=0; i<container.numChildren; i++) {
cont[i]=container.getChildAt(i)
//cont[i].z=cont[i].transform.getRelativeMatrix3D(root).position.z;

[Code].....

View 6 Replies

Flash 10 :: New 3D Tool For Rotating Around Objects?

Jun 21, 2010

Whats the 3d capability in flash cs5, I've been told there is a new 3d tool for rotating around objects. Does that mean an obj import is possible? I am eventually aiming for a series of gear wheels, one facing the screen rotating on its z axis. Is this possible.

View 0 Replies

IDE :: Dragging Objects - Rotating And Easing

Aug 22, 2009

I have two drag-related questions. The first one is how to rotate an object by clicking and holding on it, then moving the mouse round in circles. Think of a clock face, and the user clicking and holding on one of the hands, then spinning it around. The centre point would be the part of the hand that's attached to the middle of the clock face, and the other end of the hand would be able to rotate 360 degrees around the face.

The second one (and not related to the first one, a separate query altogether) is how to drag something horizontally along the screen, but have it stuck at a certain speed. So if the user tries to quickly drag the clip from left to right, it will not reach the right instantly, but instead follow the cursor at a slow speed.

View 1 Replies

ActionScript 3.0 :: Understanding Script For Rotating Objects

Aug 13, 2009

I am trying to understand what part of AS3 script says loop through(create a continues 360 loop of objects) the images from an XML file, does this make any sense.[code]is this the part that says loop the images/objects.this is a little more to the script including the above to maybe understand better?[code]

View 40 Replies

ActionScript 3.0 :: Setting Objects Width While Rotating?

Mar 24, 2010

I'm working on putting together a game at the moment which is similar in many ways to mini golf (or crazy golf, depending on where you come from). It is shown from a side-on view and to play the user must select the ball by holding the mouse down over it, then drag the mouse to indicate the direction they wish to fire the ball in. The distance they drag the mouse (this is capped obviously) determines the power of their shot.
 
I am currently using a triangular object with the tip placed at the centre of the ball to show to the user the direction they have chosen. This triangle rotates to face the position of the mouse, and I'm trying to get it to extend/shorten based on the distance from the mouse to the ball. I have code in place (below) that works when the mouse is either to the left or right of the ball, but behaves rather strangely when the mouse is above or below the ball. When the mouse is in either of the latter locations, the triangle extends to be far bigger than the maximum length allowed by the program, yet a trace shows it is still within acceptable limits! I'm almost beginning to think that Flash is switching the 'width' and 'length' attributes around when the object is rotated by either 90 or -90 degrees!
 
The code I am using is:

[Code]....
 
Here's a couple of screenshots of the game as it currently stands too - please don't laugh at the horrible placeholder art: none of it is final haha (also note that I haven't implemented 'gravity' yet, so everything is sort of hovering in mid-air.) The first image shows the code working as I want it to with the triangle at it's max width, the second shows the triangle going 'huge.'

View 6 Replies

Rotating And Throwing Objects Using Flash And Box2D 2.1a?

Jul 26, 2011

i'm using flash with box2D 2.1a. i'm rotating ball hanging on the string. The path which the rotating ball trace is ellipse. When releasing the rotating ball from the string i want the ball to fly with the obtained direction, velocity and strength. As you can see in the pictures.[URL]..I've tried to do it with setPosition (method of b2Body) and with various joints. But I haven't got the needed results.

View 2 Replies

ActionScript 3.0 :: Rotating Multiple Objects And Every Circle Around It

Nov 17, 2011

I have an idea of a game in my head and I wan't to get somekind of functional demo of it done in flash (CS3). I've looked everywhere but couldn't find tutorial for it, as I'm not sure what I'm looking for. I'm not that good in Actionscript. I'm now trying to describe this problem. On screen there's 4 rectangles, 2 in a row. So it's 2 rows with 2 rectangles in each. between all of them theres 4 circles. If I activate a rectangle with mouse and use arrow keys to rotate it smoothly 90 degrees, 2 nearest circles rotate with it. And same thing happens with all of the rectangles.

So I'm looking for somekind of solution where rotating an object also rotates every circle around it. and when circle rotates 90 degrees with rectangle as it's center point, it can be also rotated with another rectangle. I think I can't explain this clearly?

View 3 Replies

ActionScript 2.0 :: Rotating Multiple Objects On Same Path

Dec 24, 2002

There is an example of what I'm trying to do [URL]. The only difference is that I'd like to use several different objects in my file...and not only one (i.e., ball or whatever) - but different objects with different shapes, colors....circulating on the same "path".

View 1 Replies

ActionScript 2.0 :: Rotating Objects From Xml File - Modification

Oct 16, 2008

I've got on the web some code of nice rotating objects from xml file. But I need to make, that when you mouse over one object, the rotation get stopped. I don't know exactly how to do it, so I'm asking for your. Pasting bellow the code and URL example of the animation.

[Code]...

View 2 Replies

Flash8 HitTest Works Wierd With Rotating Objects?

Dec 29, 2009

How would i make hitTest work better with a rotating object(AS2). Becase i have a circle and it if gets near the rotating object (actually pretty far away) it starts the script,(new x and y)

I think thats the rotation script, becuase i took a break for like 4 days becuase it was irritating.

View 1 Replies

Flash :: Moving And Rotating Objects Along A Sine Wave?

May 27, 2011

There are a couple of problems i'm having with this - the first is how to work out how to find where the tip of each sine curve is (ie the frequency) and the second is to work out how to rotate each object so that it slides sideways along the sine wave(note file is 800 x 600)here's my code: CarouselTest.as:

package
{
import com.greensock.easing.Sine;

[code].....

View 1 Replies

ActionScript 2.0 :: Rotating / Dragging Objects Based On Keypress

Jul 22, 2002

I have a bunch of draggable objects and I want to be able to rotate them. Is it best (possible?) to rotate them based on keypress or how might you go about this. Here is my keypress code so far ( draggin works - rotate doesn't )

[Code]...

View 5 Replies







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