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


Similar Posts:


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

ActionScript 2.0 :: Whenever Move Mouse Over It , It Should Stop Rotating?

Jan 28, 2009

am new action script just started to learnstarted with 2.0 i had small scenario imagine any shape which is in rotating motion through motion tweennow what i what is through AS whenever i move mouse over it , it should stop rotating

View 1 Replies

ActionScript 3.0 :: Smoothly Rotating Object Towards Mouse

Oct 13, 2010

I am trying to make an object smoothly rotate towards the mouse.
ActionScript Code:
var rot:Number = 0;
var smoothing:int = 5;
stage.addEventListener("enterFrame", step);
function step(e:Event):void {
// point_direction is a function I have created that finds the angle between 2 points. I know this functions works as it is supposed to
rot = point_direction(obj.x, obj.y, mouseX, mouseY);
obj.rotation += (rot - obj.rotation) / smoothing;
}
This code works, except when I pass the mouse over the center of the object on the left side it seems to spin the long way around. So if I move the mouse down the center of the object on it's left side, it will spin a long way counter-clockwise to reach the mouse instead of the tiny length if it had spun clockwise.

View 3 Replies

ActionScript 2.0 :: Rotating Turret That Will Follow The Mouse 360 Degrees?

Mar 18, 2009

i am terrible at explaning things but i'm going to try my best.for example. I have a rotating turret that will follow the mouse 360 degrees.so i wonder if it is possible to go inside the turret ("mc") and stop at frame (2);when the turret reaches 170 degrees.

View 2 Replies

ActionScript 2.0 :: Stop The Object From Rotating When Roll The Mouse Over?

Jan 4, 2006

i have my fla here.

i want to stop the object from rotating when i roll the mouse over.

View 4 Replies

Flash :: IDE :: Rotating Object Either Mouse Movement Or Dragging By The User

Apr 24, 2011

Im in my final year of year 12 and need to have a car rotate in flash by either mouse movement or dragging by the user. Ive tried googling and being lower then noob level on adobe flash I have no idea about anything. I have created a car model in 3ds max. It is of high detail and I wanted to keep it that way. An example of what I wanted to create would be [URL]

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

IDE :: Rotating A MovieClip

May 12, 2010

I have a circular diagram with approximately 8 icons around the outter part of the circle. These points are all buttons. When Clicked, I want the diagram and icons to animate round to the top point (360 or 0 degrees). Then, when another icon is clicked they will all move round so that one is at the top.It would be a great bonus to have a slick easing in motion too but not essential - just a 'nice to have'.I have looked over forums and responses and there is quite a bit of info on this but I'm finding it difficult to apply it to this particular project.

View 2 Replies

ActionScript 2.0 :: CS3 Rotating Movieclip To Another Movieclip?

Apr 1, 2010

im using CS3, AS 2.0

how do you rotate the position of one MC to another. for example a triangle, i have one mc that rotates to face the mouse position but i want another mc to rotate towards the player

View 4 Replies

ActionScript 3.0 :: Rotating A MovieClip?

Apr 16, 2010

I'm trying to rotate a movieClip from it's original position, to a random anglehere's what I have:

function getRandomNumber(min:Number, max:Number):uint{  var randomNumber:Number=Math.round(Math.random()*(max-min)+min); return randomNumber;}
particles.rotate(angle:getRandomNumber(0,180));

[code]........

View 2 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 :: Rotating Movieclip Around Its Middle?

Jan 7, 2011

How do I make an mc constantly rotate? I know this must be simple but i dont know how to do it. I just want it to rotate around its middle. How would i do this?

View 1 Replies

ActionScript 2.0 :: Rotating MovieClip From 0 To 180 Degrees?

Jan 23, 2007

I've created some code that rotates an arrow up or down when the user clicks on it, depending on whether the timeline is on frame 1 or 5. The problem I am encountering is that rather than rotating visually, it just flips to the correct degree (in this case, 0 or 180).

Code:
function turndown():Void{
for(i=0; i<16; i++){
this.upDownMC._rotation += 11.25;
}} function turnup():Void{
[Code] ......

View 5 Replies

ActionScript 2.0 :: Rotating MovieClip On Slope?

Apr 21, 2007

How can I rotate a movieclip so that when I move it, it will rotate slightly depending on the angle of the ground. The only thing I can relate this too is the old school sonic games. How would I find the curve of the ground and apply it the moving character?

View 8 Replies

ActionScript 3.0 :: Dynamically Placing Movie Clip At The Angle And Global Position Of A Mouse Click (button) Which Is Constantly Rotating?

Sep 23, 2009

Does anyone know the code for finding the global positioning of  X & Y co-ordinates of a click of a button which is constantly rotating, and then secondly the code for when you click on the button it  displays a movie clip on top of it -(position of x & y when clicked) at the angle that you clicked it  (so underneath the buttons are still rotating so other people can click them where they are)to explain the context, I'm trying to design a mock up of a circular interactive table when someone comes up to it and clicks on one of the buttons that are moving, it reads where the person clicked it and opens up a new box (movie clip) where they clicked it (at the angle) so its not upside down if you are at the topI've included my .fla file which shows the four buttons moving and a little diagramexplaining what I'm trying to do.

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

Flex :: Rotating Movieclip Back To Square?

Jul 20, 2010

I have a movieclip that I am using greensocks transformManager with so the user can rotate, skew, and scale the clip. This works fine, but I am trying to add a crop tool. If the image is rotated, when I send the image to the crop tool it measures the height of the image by the bounds of the rotated image, not the actual height of the image if it were square (re: not rotated).

So, what I tried to do what, after sending it to the crop tool, rotate it back to 0 before getting the bounds using this code:

[Code]....

I don't understand the math here. Shouldn't it just rotate 3rads in the positive direction to equal it out? How would I return it to 0;

View 1 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 :: Collision Detection Within Rotating MovieClip

Feb 15, 2007

I am working on a snowboarding game, And have two points of collision detection on the board:
x-----xOne at the Front of the riders boardOne at the Back of the riders boardThese two points of collision are placed within the rider.movieClip, and not on the _root timeline, as the rider movieclip can rotate etc as it rides through different gradients of slopes. I have used a largely basic method to obtain the X,Y positions of each collision point, using the following method:

Code:
var backX:Number = _root.rider._x+_root.rider.backDetection._x;
var backY:Number = _root.rider._y+_root.rider.backDetection._y;
(The same for the frontX and frontY) As you can see, it simply adds the offset of the detection points positions from the riders x, y therefore when the rider movieclip is rotated during gameplay, the rotation is not accounted for and it still searches for collision in exactly the same positions.

I am using this for collision checking:
Code:
this.hitTest(backX, backY, true)
Which is placed on the ground movieclip (what the snowboarder is riding on). Any better way of doing such collision checking, or how to account for rotation? is localToGlobal() the answer?

View 1 Replies

Actionscript 3 :: Movieclip Stops Rotating After It's Box2D Body

Nov 30, 2011

I have made a Car Game using Box2D [in Flash] and I have one remaining bug, which I cannot fix. I added graphics and put them on top of the Box2D body. Everything went as good as expected, but after X rotations the movie clips for the car-wheels, stop spinning. I do something like this wheelSprite.rotation = wheelBody.GetAngle() * 180 / Math.PI. I ran a separate program and I saw that, if you do X.rotation += variable and you increase the variable every frame, after ~30 000 (value of variable) the MovieClip stops rotating, so I reset it to 0 after ~28 000. What do I do? The wheelBody.GetAngle()

View 2 Replies

ActionScript 2.0 :: Drag And Drop Movieclip With Rotating Control?

Oct 25, 2009

I want to make a drag and drop movie clip with rotating control in 360 degrees.I made a movie clip with 30 frames with a button in centre which can rotate the object in 360 degrees.At this stage it is functioning.when i tried to add the drag and drop action to the movie,the button for rotation is not working.

View 0 Replies







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