Actionscript 3 - Easy Rotation In 3D With Mouse In Flash RotationXYZ In 2 Directions?
Jan 5, 2011
I have a Cube which I want to rotate using mouse motion. So if I move my mouse to the left it rotates as if rotationX was increased. When I move right rotationX is increased. Moving Up and Down alters rotationY.
This looks fine as long as you modify only one dimension (either rotationX or rotationY). But if I have already changed rotationX and then try to modify rotationY the results are weird. If rotationX is 180 rotationY effects are reversed. It basically is quite unpredictable and certainly not suitable for user.
I have tried to look around (failed), read about quaternions (couldn't understand), tried some out of blue and very complex trigonometric calculations (made a fool out of myself) and so I am stuck now. I've found this SO question Best way to translate mouse drag motion into 3d rotation of an object but it doesn't help me a bit, I can't understand any of the answers, really.
View 1 Replies
Similar Posts:
Jul 17, 2009
I feel dumb for asking this....but what is the best way to make an object rotate (counter-clockwise in this case) indefinitely? ENTER_FRAME listener that offsets the angle by a certain number of degrees per frame? more economical way?
View 3 Replies
Jun 25, 2010
Essentially what I'm trying to do is nearly the same as this: http:[url].......However I'd like to ease/tween the movieclip position and rotation to the mouse position.The main issue I see is trying to get the current movieclip rotation and the target rotation,then tween it cockwise or counterclockwise from current to target.The way a movieclips rotation uses positive and negative numbers throws it off.If you just want to lock the mc rotation to the mouse rotation its fine, but once you try to tween it you run into difficulties. So the end effect would be like if you were to draw imaginary clockwise circles around the object, it should just keep rotating clockwise towards the mouse. Then if you started going counter clockwise it should just keep easing counter clockwise to the mouse.
View 1 Replies
Apr 19, 2011
i create this code but i cant spinning it with mouse (when i hold it)
Code: Select allmthr.addEventListener(Event.ENTER_FRAME,rotate);
function rotate (e:Event)
{[code]....
View 3 Replies
Feb 1, 2011
I'm getting reduced image quality when I modify my MovieClip's .rotationY property. I've read that flash converts the object into a bitmap which explains the reduction in quality. However my MovieClip will eventually return to it's default position .rotationY = 0; and i don't want it to have a loss in quality.
View 1 Replies
Apr 17, 2009
i was wondering if theres a way to link the amount and direction of an objects rotation to the mouse position. I want it so if you move the mouse far to the left the object spins fast anticlockwise but if you move it to the center it stops.
View 2 Replies
Aug 15, 2009
I have done the rotation bit, but now i want to limit the rotation but i can't do it
this is my code -
PHP Code:
stage.addEventListener(Event.ENTER_FRAME, moveArm)
function moveArm(e:Event):void
[code].....
View 2 Replies
Sep 10, 2011
I created a map with the Google Map API For Flash that shows directions. It creates a line between the 2 addresses and gives turnbyturn directions.
This is working perfectly in Flash test mode locally but once i put it online The map still works but the directions dont show and i get the Failure status 400.
Does anywone know whats the problem here? I'ts driving me crazy just because its working locally but not online.
DirectionsEvent.DIRECTIONS_FAILURE.feature.status = 400
View 2 Replies
Mar 16, 2011
I want to make a game using physics in Flash, so I stumbled upon Box2D, but i find that hard to use [the basics are simple, but when i see the scripts,so i was wondering if there are easy to use flash physics engines?
View 6 Replies
Mar 2, 2009
I've recently created a game in which the logic and programming all runs perfectly, however the graphics are lackluster. I'm currently having a hard time managing the depth of movieclips on the screen.Basically the game is tile based and each frame of the movieclip holds a different type of tile. All the tiles are 50x50 with the exception of one type of tile which is 60x60 and therein needs to overlap the tiles around it which are 50x50.In AS2 I could of set the depth manually, however I'm told (as is this is my first time dealing with depth in AS3) that I cannot do this anymore. Is there any suggestions on how I can make sure that a tile of one type is automatically set beneath tiles of another type - I've thought about simply coding a function to check this but it somehow seems inefficient (considering larger maps will have a lot of tiles, meaning hundreds of movieclips attached to the stage, each movieclip with multiple frames).
View 2 Replies
Feb 1, 2010
How do I rotate an object with the mouse after I have dragged the object with mouse.ssentially, I want to move the object with the mouse and then rotate it with another mouse click. Right now the object is moving and rotating at the sime time.
View 6 Replies
Jul 21, 2009
I want to know if there is a way to determine the rotation of mouse movements flawlessly. this will trace the direction I am going in.
[Code]...
View 2 Replies
May 31, 2011
My goal is to make it so that when the user clicks and drags the disc (whether it be click anywhere on the stage or clicking on the disc itself), the disk will turn according to where the mouse goes.
I've used this tutorial [URL] to make a simple arrow move when the mouse does to test the code and see if it works, and it does. But now i'm trying to figure out how to make it so it will only move when I drag the mouse. I've tried things like "onClipEvent (mouseDown)" and such but they don't drag the clip.
how to get the arrow/disc to drag (and eventually, play a sound, but I will worry about that later),
code on MC:
Code:
onClipEvent (mouseMove) {
x = this._xmouse;
y = this._ymouse*-1;
[Code]....
View 0 Replies
Jul 12, 2011
I cant get the flash to work on my website. I have also tried using countless versions of the 'AC_RunActiveContent.js' wrapper with this, but it just ends up as a white block, whereas if I just use the following code I get a black block. So I am certain that the path is correct because if I change the src path, it becomes a white block.
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="[URL]"WIDTH="796" HEIGHT="300" id="banner">
<PARAM NAME=movie VALUE="banner.swf">
<PARAM NAME=quality VALUE=high>
<EMBED src="/myfolder/banner.swf" quality=high WIDTH="796" HEIGHT="300"NAME="banner" ALIGN="" TYPE="application/x-shockwave-flash"PLUGINSPAGE="[URL]"></EMBED></OBJECT>
View 3 Replies
Aug 29, 2009
I've got a very simple AS2 test file here:URL...I have a simple triangle, and it follows the mouse as it moves around.I'd like to get the triangle to change rotation, to follow the mouse, but my so far bodged version doesn't do that very elegantly.I have this AS on the MC that follows the mouse:[code]
View 3 Replies
Nov 8, 2009
I'm not really replacing the mouse cursor exactly. Just placing a custom image of a pointer below it so it will follow the mouse cursor as it moves around the screen. I want this pointer image to move with the mouse and to rotate and point in the direction the mouse is traveling. Simple stuff. The problem is that the rotation of the pointer graphic is not smooth at all. It is jumpy and somewhat erratic particularly at slower mouse speeds. When the mouse is moving quickly the problem seems to go away.
PHP Code:
package {
import flash.display.Sprite;
import flash.events.*;
public class MouseFollower extends Sprite {
private var pointer:Pointer = new Pointer(); // ...a simple triangle mc
[Code] .....
View 2 Replies
Sep 30, 2009
I have a circle wheel i want to rotate and the speed should be based on the mouse position. I also need to have easing in and out.
When the user hovers over the bottom of the circle it will begin to rotate one way and then th top of the circle would make it rotate the other way. The further to the top or bottom they are the quick it spins. It ideally needs to ease in and out when it starts and stops when the user moves the mouse away.
The circle will be the complete movie so 50% top and bottom each for each direction.
View 1 Replies
Aug 6, 2011
The player rotates to the mouse when you click somewhere and moves there. The problem is sometimes when you click on a corner the player rotates towards where you clicked but sometimes starts moving sideways.
View 3 Replies
May 8, 2009
I'm trying to make a movieclip rotate around it's center (this is no problem since the center will never change). The problem that I am having is when I press the movieclip, in let's say the bottomright corner, and move the mouse the movieclip flips to a certain angle depending on my mouseposition. After the weird flip it works fine but it's the initial mouse click that makes the movieclip flip to an angle.I've tried playing around with different values to substract or add the starting angle but eveytime the result is not what i am looking for.Current code:
Code: Select all
package
{
[code].....
View 8 Replies
Jul 21, 2006
how to use trig to rotate a movie clip based on (my_mc._x, my_mc._y) and (_root._xmouse, _root._ymouse)?
View 1 Replies
Jun 14, 2007
I'm trying to make it ease to the spot but it doens't seem like there is a way.
It is jumpy, i would like to it to slowly smooth to the current mouse location. It's going to be used for a touch screen
Heres my current AS:
Code:
stop()
face.onRollOver = function(){
startDrag("mouseTarget", true);
[Code]....
View 1 Replies
May 2, 2009
right now I have a code that rotates an object based on the position of it and the mouse. Thats all great but it sucks for a game, It is way too responsive. What I tried doing is making to rotation var:
[Code]...
after that I made rot2 the direct rotation between the object and the mouse: rot2 = Math.atan2(Ydiff, Xdiff) * 180/Math.PI; //(forgive me if this has spelling errors, as I am writing it //by hand right now) then I make rot effect the object: object.rotation = rot; now that the basics are set up I just need to make a code that compares rot2 and rot, if rot is less than rot2 it adds on to rot, if it is greater, then it will subtract.
(source at bottom) this all works well until you hit the most annoying part, the one i cant figure out how to fix.... basically there is a gap where the numbers go from 180 to -180, so the code flips out, reads this as it is supposed to, but this makes the object rotate a full 360 degrees around instead of just like 2 degrees to bridge the gap. If anyone has insight on this or thinks they might know what to do,
[Code]....
View 3 Replies
Sep 12, 2009
I am trying to create a effect using AS3. The effect is that several arms should rotate towards the mouse, and rotate less when their further away from the mouse cursor.using Math.atan2 to find how much the arm nedd to rotate to point against the mouse, and then substract the distance from the mouse.(look at the following picture) For example, if Math.atan2 returns 100 and the distance from the mouse is 40, the arm would rotate 60. Thats what i thought.But i cant get it to work. I attached the source files if you want to help Note:A blue ring in the source file indicates the distance.
View 2 Replies
Apr 29, 2010
I have this code is AS3
Code:
var xMouse = mouseX;
var yMouse = mouseY;
[Code]...
But unfortunately, the ship does not follow mouse rotation. The ship only rotates with respect to the mouse when you move the ship, not when you move the mouse.
View 1 Replies
Jan 24, 2011
I have researched all over and have found some that "kind of" work, but the coding always has issues with CS3 (my version). I am more proficient in AS2, but would be willing to try AS3 if that is the way to go.I need a script that will allow the user to use their mouse to drag a wheel that will slow down to a stop. Think "Wheel of Fortune" style. Where it stops will trigger an event.
View 4 Replies
Aug 16, 2005
First off, lemme start by saying that this site is incredibly awesome. Every time I have a problem or wish to learn something in Flash I turn to [URL]. Now for my problem. Have you ever played Madness? You know how, depending on where the mouse is, the hand rotates i.e. points at the mouse's current position? Well, I want to learn how to do that. I've attached a short animation demonstrating what I want to be able to do (the arrow points at the mouse's position, and then gun represents the movie clip that rotates) using a script
View 6 Replies
Nov 30, 2009
I have created a globe that rotates with no problem, but what I am trying to do is to control the direction of the rotation based on the mouse position. For example, if the mouse is to the right of the globe, it rotates towards the right and if the mouse in on the left, the globe rotates left. When the mouse is over the globe, it should stop.
View 1 Replies
Jun 25, 2010
I'd like to ease/tween the movieclip position and rotation to the mouse position.The main issue I see is trying to get the current movieclip rotation and the target rotation, then tween it cockwise or counterclockwise from current to target. The way a movieclips rotation uses positive and negative numbers throws it off. If you just want to lock the mc rotation to the mouse rotation its fine, but once you try to tween it you run into difficulties. So the end effect im looking for would be like if you were to draw imaginary clockwise circles around the object, it should just keep rotating clockwise towards the mouse. Then if you started going counter clockwise it should just keep easing counter clockwise to the mouse.
View 3 Replies
May 9, 2011
i create stage Mouse Rotation Y is complete and i want to put some easing on movieclip this is my code
Code:
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(event:Event):void
{
[Code]...
View 3 Replies
Nov 16, 2009
I want the diameter of the 'balls' orbit to change dependant on the position of the mouse but keep the point of rotation exactly the middle of the stage at all times.I.e. if the mouse is hovering over the exact center (both X+Y) of the stage then the 'ball' should have a tiny diameter of rotation (but contstantly follows the orbit in clockwise direction) whilst if you move the mouse towards the edge of the stage then the diameter of the orbit of the ball will increase.Here is the AS which controls a blank movieclip;
var sp:Sprite = new Sprite();
orb1.addChild(sp)
var g: Graphics =sp.graphics
[code]....
View 1 Replies