I'm writing a class for an instrment and one of the knobs has "snapping" values at X degrees.I have the code to make the knob snap to the set degrees,but I'm having trouble getting it to determine whether it was rotated clockwise or counter-clockwise.Here is the function that makes it rotate and "snap" The majority of the problem is because of the 0/360 and negative values that Flash has when it rotates..
In the function:
the _baseMovieClip is the clip that contains a graphic to rotate and "snap" to the degrees.
the _clipToRotate is a movie clip that actually displays the rotation
the _startAngle is the angle the user clicked on the button that triggers rotation
the _rotateObj is a sprite that is drawn when they click that I make visible to show the actual rotation when I'm debugging
the _snapLock is the degrees the knob shold rotate to (10, 15, 30, etc)
private function calculateRotation(event:Event):void [code]....
I have a function that lets you click on a handle of a movieClip and rotate it. I recently updated my code to make use of Oscar Trelles DynamicMovie class so I could set a registration point in the center of the movieClip. But that has given me problems with being able to rotate the movieClip incrementally in an anti-clockwise manner.
The following code will let me rotate it clockwise, forever and ever. But I'm having a hard time wrapping my head around how to determine if the user user is dragging the mouse counterclockwise. The property mc.rotAng is set in a previous mouseDown event. It stores the previous mouse position, and the incremental angle of rotation is derived from the current mouse position and the old mouse position.
I have 2 movieclips. ro used for rotating and rect the movie that will be rotated.
I want when clicking and draging the ro movieclip clockwise or counterclockwise, the rect movieclip is rotated clockwise or counterclockwise respectively.
I allow the rect to be rotated according to mouseX and mouseY.
but it dose not work as I need.
I'd like you to show me a trick to achieve that as I want.
Here is the code:
var xPo:Number; var yPo:Number; ro.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down) function mouse_down(e:MouseEvent):void
Ok, here is my problem, hard to explain tho, but i will do my best.I would like a circle picture to dissappear (or appear) with like a clockwise motion. So basically from twelve oclock i want the circle picture start going away clockwise until it comes to twelve again and the picture would be all gone by then.
I am sure this is simple, but cannot remember how it is done. I just need to rotate an item counter clockwise 1/2 a time. The rotate option only accepts integers and when I do a motion tween it goes clockwise.
one after the other in a clockwise manner, so that they form one big enclosing square. In my script, I have a square called cell_mc that I would like duplicate instances of cell_mc to enclose to form a bounding box. I would like the duplicate instances to be drawn one by one in a clockwise direction:
ActionScript Code: // Get depth var depth:Number = this.getNextHighestDepth();
I wish to have a function that will take as input a radius value and a magnitude value.
It will return firstly a point (x,y) and also secondly a direction, (vx,vy) which will have a certain magnitude(speed).
The point returned will be a random point within the radius value and the direction will be a a (vx,xy) that moves the point perpendicular to the line segment (x,y) ->(centrepoint).
Essentially I'm just trying to rotate an object (mc) clockwise or anticlockwise depending on the value of a variable called 'angle'.If 'angle' is positive it should go anticlockwise.If 'angle' is negative it should go clockwise.
i would like spin an object in clockwise and anticlockwise direction with ease via press of a button.tried using,
on (press) { this.testmovieclip._rotation += 45; }
just to get the object to turn... What i wanna do is have 4 buttons, 1st button turns the object 45 degrees, then 2nd button turns it next 45 degrees and so on... Have attached .fla of what im trying to achieve.
here is some code for a rotating crank that controls an image gallery. refer to the "image viewer stops?" thread in the flash mx forum (sorry don't know how to link to a forum yet!) for more info. attached is the fla. i want to be able to crank clockwise to scroll images forward and counterclockwise to scroll images backwards. If i keep cranking, i want the images to continue to change, if i stop cranking, i want it to stp on that image. it doesn't sem tooooo hard, i'm just numb from tryig to figure it out.
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.
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
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));
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.
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.
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?
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] ......
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?
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
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;
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?
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?
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?
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()