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


Similar Posts:


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 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 3.0 :: Rotating A Movieclip Using The Mouse?

Mar 30, 2009

I have been trying to convert this effect into AS3 but have been having majour issues : rotate clip

I have an object (class) with a handle, when dragged I would like the clip to rotate with the mouse (much like rotating an object in photoshop). I have put my code into an ENTER_FRAME event, and have been using a matrix object to do my rotation (is there an easier way?)

Code:
private function rotateClip(e:Event)
{
myMatrix.rotate((Math.floor(180*Math.atan2(mouseX,mouseY)/Math.PI)+90));

[Code].....

was my attempt at converting the code from the example link. I've also tried various other methods using trig to no avail.

View 1 Replies

ActionScript 2.0 :: Rotating MovieClip Towards Mouse Position

Feb 12, 2005

Any way to rotate a movieclip to face the mouse location?

View 1 Replies

ActionScript 3.0 :: Horizontal Scrolling Movieclip That Scrolls When The Mouse Is Left Or Right Of A Certain Point Of That Movieclip

Aug 11, 2009

I have a horizontal scrolling movieclip that scrolls when the mouse is left or right of a certain point of that movieclip. However, it only moves slightly then stops when the cursor goes over it, it doesnt actually scroll normally...

[Code]...

View 1 Replies

ActionScript 3.0 :: Hit Test Point NOT Detecting A Bottom Movieclip If The Mouse Is Over The Top Movieclip?

Oct 2, 2009

i have 2 intersecting movieclips.

is there a way to hit test point NOT detecting a bottom movieclip if the mouse is over the top movieclip?

View 3 Replies

ActionScript 2.0 :: Make A Movieclip In Flash That Makes Buttons Spin Around A Point Depending On The Mouse Position?

Oct 9, 2007

I have recently followed a tutorial to make a movieclip in flash that makes buttons spin around a point depending on the mouse position. I have made my own version off this and would like to use it in a full flash website that i am making at the moment.

The only problem that i am having is with aligning this clip and as it is made up of script i cant physicly drag it to were i want it. I understand how to alighn this with x/y positioning but when i preview the flash in a web browser it is positioned correctly but then when i 'full screen' the browser this clip jumps about 4 inches down the page.

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

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 2.0 :: Drawing Api - The Curve Point Be The Same Point As The Mouse?

Nov 3, 2003

From the Robert Penner code given in this tutorial: [URL] i was wondering why controlx and controly has to be so complicated. I've tried changing it to just _root._xmouse but it messes up. I don't get this, shouldn't the curve point be the same point as the mouse?

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

ActionScript 2.0 :: Rotating A Movable Movieclp Around A Spcific Point?

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

ActionScript 2.0 :: Rotating Draggable Point About Circumference Of Circle?

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

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 :: Movieclip To Move Along The X-axis To A Certain Point And Then Back To The Starting Point Again?

Apr 12, 2007

It's been a long time since I've done any work with actionscript, and alas I've forgotten nearly everything. I've tried to look for a tutorial that would explain basic animation with actionscript, but the one that I found on Kirupa was no longer there.

Basically I'd like to do this:On the stage I have a movieclip and I'd like the movieclip to move along the x-axis to a certain point and then back to the starting point again. The moving speed of the movieclip should also be adjustable.

View 8 Replies

ActionScript 2.0 :: [CS3] Rotating Using Mouse Coordinates

Mar 12, 2008

I'm trying to create a simple site that when you move the mouse to the right of the screen a movie clip rotates one way abt 45 degrees and moves the other way when the mouse moves to the left.

I'm trying to get the effect of a horizon line rotating to the mouses movement around the screen.

View 10 Replies

Object Following Mouse, Rotating Left And Right?

Oct 11, 2010

I am working in AS2 and I have a flash project that is almost complete but I would like 1 thing modified.I have a fish image following my mouse.

(script below)
onClipEvent (enterFrame) {
_root.yChange = Math.round(_root._ymouse-this._y);[code]...........

The problem is that I would like the fish image to "turn" and face the direction of the mouse. Currently, as is, the fish follows the mouse fine when the mouse is moving to the right, but when it goes to the left the fish swims backwards rather than turns and swims the correct way following the mouse to the left.How would I modify the script to get the fish to turn and always swim forward when going left and right?

View 3 Replies

ActionScript 1/2 :: Rotating Through Frames Via The Mouse?

Sep 21, 2009

I am working on an animation that I need to rotate in flash, via the mouse?
 
Is there a way to cycle through the frames left and right via the movement of the mouse?

View 8 Replies

Actionscript 3.0 :: Rotating To The Mouse Position?

Apr 8, 2009

Im trying to follow an example and get a simple arrow sprite to rotate to the mouse position. This example comes out of the book 'Foundation Actionscript 3.0 Making things move' however when I build the following .as files, open a new as3.0 document, assign the document class to RotateToMouse, run the movie the swf's stage is blank and lacking the arrow sprite im telling it to create.

Code:
Code: Select allpackage
{

[code]....

View 1 Replies

ActionScript 3.0 :: Rotating Circle By 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 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 2.0 :: AS2 Hittest On Rotating Shapes /w Mouse

Mar 27, 2011

I've googled for hours and found nothing. I did find a lot but none involved hittesting with a mouse cursor. I'm trying to make a simple maze game, so far it works, I die when I hit squares and rectangles, but I die incorrectly when hitting a rotating rectangle.Because it rotates, the bounding box is larger and a normal hittest sees bounding boxes, meaning it won't work.Make it so that my mouse can go near the rotating rectangle without dying until I actually touch the actual rectangle instead of the bounding box.

View 2 Replies







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