ActionScript 3.0 :: MC Rotate And Face Mouse With Tween

Oct 24, 2010

I'm trying to get a MC to rotate to face the mouse using tween:
Code:
import flash.events.MouseEvent;
import fl.transitions.Tween;
stage.addEventListener(MouseEvent.CLICK,clicks);
var tween:Tween;
function clicks(e:MouseEvent):void {
var dx:Number = mouseX-mc.x;
var dy:Number = mouseY-mc.y;
var angle:Number = Math.atan2(dy,dx)*180/Math.PI+90;
tween = new Tween(mc,"rotation",null,mc.rotation,angle,5);
}
While this works fine, there are certain clicks which make the MC pick the longer route to rotate.

View 2 Replies


Similar Posts:


ActionScript 2.0 :: Rotate A Movieclip To Face The Mouse Location

Feb 12, 2005

rotate a movieclip to face the mouse location

View 1 Replies

ActionScript 3.0 :: How To Get MovieClip To Face Mouse

Sep 17, 2009

I'm making a top down shooter and I'm encountering some interesting code lag with the function I'm using to make the player face the mouse.

Code:
//The function is called through a ENTER_FRAME listener.
//mX & mY are the current position of the mouse.
public function facePoint(mX, mY){
if(this.visible){
this.rotation = (-Math.atan2((this.x - mX),(this.y - mY))) * 180 / Math.PI;
}}

If I hold down two movement keys and then spin the mouse around the character really fast, it builds up some kind of buffer that sends the character out of control for a few seconds, even after you've released the keys. Just discovered that reducing the quality to low removes the issue entirely... so its a graphics problem. How to avoid this?

View 1 Replies

ActionScript 2.0 :: Make Character Face Mouse?

Dec 24, 2011

How would I go about doing this but not directly like 360. like lets say my mouse is to the left of the character the character would than face its left frame I made for him like lets say his left frame is frame 2.

View 8 Replies

ActionScript 2.0 :: Make Charater Face Mouse Platform?

Aug 16, 2011

I have my as2 code for my game im making so far the char can jump and move left and right. make him face the mouse like lets say my mouse is to the x- of my character than I would want his left facing movie clip (which I havent made yet) to be facing that way etc. where I could start heres what I have:

Actionscript Code:
onClipEvent (load) {var ground:MovieClip = _root.ground;var grav:Number = 0;var gravity:Number = 2;var speed:Number = 7;var maxJump:Number = -12;var touchingGround:Boolean = false;}onClipEvent (enterFrame) {_y += grav;grav +=

[Code].....

That's the movement code that lets me move left and right and jump with gravity

View 2 Replies

Rotate Using The Tween Class?

Jan 31, 2010

I have a movie clip that is rotated when a button is clicked:

Quote:

mc_rightBtn.addEventListener(MouseEvent.CLICK, onRotateRight);
function onRotateRight(evt:MouseEvent):void {
var myTweenRotation:Tween = new Tween(mc_gallery, "rotation", Elastic.easeOut, 0, 90, 5, true);
}

The problem I have is that when the the right button (mc_rightBtn) is clicked again, the rotation starts from the original position. Ideally I would like the rotation to continue from its current position.

View 3 Replies

ActionScript 2.0 :: Rotate A MC Like A Motion Tween?

Feb 25, 2002

can i rotate a MC like a motion tween, but without the motion tween? i want to press a button and the MC will rotate 360 degrees...

View 14 Replies

Cube Rotate On Its Y Axis Using The Tween Class?

Jun 15, 2009

Is it possible at all to have a cube rotate on its Y axis using the Tween class? transitionManager only seems to  allow rotation around the z axis.. Is Papervision 3D the only way to achieve this? It seems awfully difficult for a newbie such as myself.

View 1 Replies

ActionScript 2.0 :: Top Image To Tween To The Right And Up In X And Y Direction And Also Slightly Rotate

Apr 15, 2007

I am updating source code I came across to AS 2.0 and I am having problems with the tweens. Here is what I am trying to accomplish in AS2.0:[URL] Here is the part of my updated code I am having problems with:

[Code]...

This is my problem: (1) I want the top image to tween to the right and up in X and Y direction and also slightly rotate. THEN I want it to tween back underneath the other stack of pictures in center of swf. However what is happening is that the depth of the topimage is being set under all the pics right away and the tween takes place under all the pics and not ontop. Is there a way for me to wait until the tweens are done and then execute my swapDepths line? Here are problem lines in detail:

[Code]...

View 1 Replies

ActionScript 2.0 :: Use The Tween Class To First Rotate An Object And Then After The Rotation Is Finished?

Mar 21, 2006

I am trying to use the Tween class to first rotate an object and then after the rotation is finished, use a new tween to move the object off the screen. Here is my code:

[Code]...

The trace runs, just as expected, right after the first Tween completes. But the second Tween doesn't work. What am I doing wrong?

View 1 Replies

Rotate With Mouse Movement?

Jul 15, 2009

I'm trying to make a dummy from a circular menu that reacts (rotate) to mouse movement, I uploaded a fla example, different colors, size, etc, but essentially the same in

function; but for now I'm freezed how to do somethings, I'm not a programer or actionscripter, but I want to learn.Currently using CS3 and AS2, downloading the FLA example may help.

Ok, in the "fla", you will see a circle who rotates versus mouse movement (I would like to make a delay rotation for a smooth feelling when mouse is moving, those like "_x += (_xmouse/5)" but with rotation. Other thing I would like to do,is... that the movement stops progressively a few degrees before the mouse reach de cian angles(a1,a2), and then, the circles doesn't move if the mouse is moving under those angles, like a... an inactive area(U1), and if it could work with instances.

View 1 Replies

ActionScript 3.0 :: Rotate After Mouse?

Jun 21, 2010

I am wondering how I can make a top viewed char, that is rotating after my mouse. With an enter frame function or something?

View 1 Replies

ActionScript 3.0 :: Using Mouse To Rotate Mc?

Oct 14, 2010

I am having problems finding a way to rotate an object with mouse movement when the mouse is down, and stop the rotation when the mouse is released.

I can do drag and drop ok but this doesn't help at all.

View 3 Replies

ActionScript 3.0 :: Rotate MovieClip Towards Mouse

Nov 26, 2010

I made a game in AS2 where the player rotates towards the mouse, then discovered you need AS3 for 3D things(which I plan to add later) so I re-made the game in AS3. I think I can more or less do the rest of it but the rotation is driving me crazy. This code works fine in AS2 but when I try it in AS3 it completely fails. The player just wobbles about a 90 degree radius.

[Code]....

View 1 Replies

ActionScript 3.0 :: Rotate MC Relative To Mouse?

Oct 29, 2009

I'm using the following code to rotate a MC on the Y axis that stops at a certain point. Is there any way to do the same using the tween class so it has a softer finish.

addEventListener(Event.ENTER_FRAME, mcRotation);
function mcRotation(event:Event):void
{
var controller:Number = mouseX - stage.stageWidth * 0.5

[Code].....

View 1 Replies

ActionScript 2.0 :: Rotate MC Based On Mouse Y Value?

Sep 27, 2010

I'm trying to achieve the effect found on this site:As you can see, the cursor (the marker) slowly rotates, based on the Y value of the mouse

View 1 Replies

ActionScript 3.0 :: Rotate In The Direction Of The Mouse?

Feb 11, 2012

I am horrible at maths and I would like to ask how to make an object ex. an arrow turn into direction of the mouse?ENTER_FRAME and some mathematical functions, but I cant tell which and how to use them.

View 2 Replies

ActionScript 2.0 :: Rotate Mc By Mouse Movement?

Apr 12, 2006

i'm trying to build a "circular" menu that rotate on rollover and mouse move but with no good results. Just something like the yugo sliding menu but with buttons placed around a circonference.I don't need a dinamic menuI need a function that let the menu rotate up when cursor is below the half of the circle and viceversa.I've done a search and found a compass example but i really can't edit it. I'm a newbee and can't really figure out how to rotate a movie clip around its own axes on mouse move..

View 4 Replies

ActionScript 3.0 :: Rotate A Sphere With The Mouse On The X And Y Axis?

Nov 6, 2009

I am trying to rotate a sphere with the mouse on the x and y axis but the sphere keeps 'roll'ing and flipping it all around.

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;

[code]....

View 1 Replies

ActionScript 2.0 :: Rotate Movie Clip With Mouse

Jul 17, 2011

I want to rotate a movie clip with the mouse and I have this code:[code]Neither looks like what I want. The first image is okay until its rotated, and the second is blurry but looks better than the first when its rotating.So I have two questions.Is there a way to get better image quality when my image is rotating with out using a bitmap?Can some one give me a code example that changes the frame in the symbol based on the position of the cursor to the symbol?

View 1 Replies

ActionScript 2.0 :: Rotate Circle With Mouse Movement?

Jul 15, 2009

I'm trying to make a dummy from a circular menu that reacts (rotate) to mouse movement, I uploaded a fla example, different colors, size, etc, but essentially the same in function; but for now I'm freezed how to do somethings, I'm not a programer or actionscripter, but I want to learn.Currently using CS3 and AS2, downloading the FLA example may help. in the "fla", you will see a circle who rotates versus mouse movement (I would like to make a delay rotation for a smooth feelling when mouse is moving, those like "_x += (_xmouse/5)" but with rotation. Other thing I would like to do,is... that the movement stops progressively a few degrees before the mouse reach de cian angles(a1,a2), and then, the circles doesn't move if the mouse is moving under those angles, like a... an inactive area(U1), and if it could work with instances.

View 0 Replies

ActionScript 2.0 :: Rotate Towards Mouse W/ Boundaries And Reflection?

Oct 20, 2003

I'm using the code 'rotate towards the mouse' from [URL].. It works fine to rotate the clip, but there's two things I'd like to have happen here: 1. At a certain angle of rotation, the MC that is following the mouse reflects horizontally. example: a profile of a head is following the mouse. i don't want the head to be upside down when the mouse reaches the back of the head, but rather the head flips over to watch the mouse.

2. Boundaries: is there some way to set up the code so that the MC stops following the mouse when it reaches a certain position on the Y-axis?

View 3 Replies

ActionScript 2.0 :: Trigonometry - Rotate Slowly To The Mouse?

Dec 20, 2005

i know how to check the angle between my object and the mouse, but i dont know how to make it rotate slowly to it...

i tried this codes:

Code:
//first method:
onClipEvent (enterFrame) {
this._rotation = (Math.atan2(_root._ymouse-this._y, _root._xmouse-

[Code]....

View 9 Replies

ActionScript 2.0 :: Rotate On Axis With Mouse Easing?

Apr 20, 2006

I have a mc that I want to continously rotate, I want it to rotate in whatever direction the mouse is from the center of the mc. If the user pulls the mouse out I would like for it to speed up and slow down accordingly.If this is not possible, I wouldnt cry. Any way when the user goes over a desiginated area I would like for the motion to stop until they pull away again.How would I go about doing this.I've seen this thread but don't understand where to attach the script, and I also need the stopping script

View 1 Replies

ActionScript 2.0 :: Object Rotate With Mouse On Stage

Apr 29, 2003

I want a ship or something in the center of the stage and to be able to click and the thing will shoot at the mouse. I know how to get it to shoot at the angle. I just don't know how to get the rotation with the mouse. I can do it with keys but not with the mouse. What I need object rotates pointing to mouse...

View 2 Replies

ActionScript 2.0 :: Rotate Movieclip On Mouse Press?

Jan 22, 2008

I have attached my fla. I want rotate the mc by Mouse drag. But its get some of the jerk.

View 1 Replies

ActionScript 3.0 :: Rotate On Drag Not Mouse Position?

Feb 24, 2009

i have some script that creates a rotating video wall/carousel effect that rotates left and right depending on where the mouse is.I want the carousel to only rotate when the mouse is down and dragging - but just can't seem to work out what i need to change.how do I define the drag action instead of the current +x & -x co-ordinates?here is the full script for the entire carousel

Code:
*/
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;

[code]....

View 4 Replies

ActionScript 3.0 :: Mouse Drag Frame Rotate?

Apr 2, 2009

I have a 40 frame animation that in sequence rotates an image. That I need to add a mouse drag function so I can scrub through the images like here

http:[url].....

View 1 Replies

ActionScript 2.0 :: Rotate Circle With Mouse Movement

Jul 15, 2009

I'm trying to make a dummy from a circular menu that reacts (rotate) to mouse movement, I uploaded a fla example, different colors, size, etc, but essentially the same in function; but for now I'm freezed how to do somethings, I'm not a programer or actionscripter, but I want to learn. Currently using CS3 and AS2, downloading the FLA.

Ok, in the "fla", you will see a circle who rotates versus mouse movement (I would like to make a delay rotation for a smooth feelling when mouse is moving, those like "_x += (_xmouse/5)" but with rotation. Other thing I would like to do,is... that the movement stops progressively a few degrees before the mouse reach de cian angles(a1,a2), and then, the circles doesn't move if the mouse is moving under those angles, like a... an inactive area(U1), and if it could work with instances.

View 1 Replies

ActionScript 2.0 :: Rotate Towards Mouse With Boundaries And Reflection?

Oct 20, 2003

I'm using the code 'rotate towards the mouse' from [URL]

It works fine to rotate the clip, but there's two things I'd like to have happen here:

1. At a certain angle of rotation, the MC that is following the mouse reflects horizontally. example: a profile of a head is following the mouse. i don't want the head to be upside down when the mouse reaches the back of the head, but rather the head flips over to watch the mouse.

2. Boundaries: is there some way to set up the code so that the MC stops following the mouse when it reaches a certain position on the Y-axis?

I'm using Flash MX or MX 2k4, whichever is more convenient for this project.

View 3 Replies







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