ActionScript 3.0 :: Mouse Drag Frame Rotate?
Apr 2, 2009I 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].....
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].....
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]....
Is it possible to rotate movieclip, while dragging, according to mouse direction and mouse x, y on that clip.
on the picture the 0, 0 of the mc containing red box is where the lines cross, the mouse point is indicated with cursor and around it is the circle where clip's x and y should be constrained and movieclip should rotate according to mouse movement direction for example: when mouse is moving straight down then the clip's x, y rotates up and stops when its 12 o'clock...
I am having problems with this Flash movie of an draggable, rotatable XML blog. I have got the XML stuff working OK. I'm just having problems making the drag-to-rotate thing work. I want it to be able to be moved around the page like a piece of paper and rotated such.
View 1 RepliesI have an object I need to rotate by clicking and dragging. Following some AS2 code I got the object to rotate a bit every time the mouse is clicked, but can't get it to work with drag.
needle.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
function fl_ClickToDrag_2(event:MouseEvent):void
[Code].....
I want functionality of Drag and Rotate to my MovieClip just like this example [URL] Or
View 2 RepliesI want to have an image and when I click on the image ,one can hold down the mouse and drag a copy to where ever on the stage and when one lets go, one can drag another and another with each copy still being able to be dragged after released.this is what i have but its pretty simple and doesn't work....
stage.addEventListener(MouseEvent.MOUSE_DOWN,makeA Box);
var i:Number = 1; //i will be the total number of boxes
var newBox:myMC = new myMC();[code]....
I am trying to create a drag and throw effect I have most of the effect working correctly but I am wondering how to only move one item at a time and have that thrown unaffected til the friction brings the item to a stop. what happens currently is if an mc is moving and you select another it moves both items.
Code:
var mx0; // Previous Mouse X Position
var my0; // Previous Mouse Y Position
var velocityX = 0; // Velocity in X Direction[code]...................
Would like to develop simple (in browser) puzzle games where shapes (such as a puzzle piece shape) can be simultaneously dragged and rotated, then dropped on the screen or canvas. The game mode would be to click and drag the shape or object, while simultaneously rotating the piece using arrow keys Is this possible in Flash? This simple general activity of simultaneous drag and rotate, then drop, is my intended overallweb site game basis. I'm new to Flash but have developed Windows executables for many years. I'm trying to decide whether to purchase and learn Flash as platform for interactive educational puzzle games running in browser windows.
View 4 RepliesI've recently downloaded a great gallery from FFILES.COM. Here's the link: [URL]
I want to add in a menu bar at the bottom of the gallery. Meaning to say, all the photos that load up from the XML will be behind the menu bar. I tried with creating a new layer on top of every other things (inserted a rectangle box for testing), but the photos for the gallery comes infront of my rectangle box.
Basically what I am trying to do is have my movie clip rotate/pivot when I press on it, same as the arm on the record player of this [URL]. At the moment, the movie clip rotates according to mouse follow, but I would like to click, drag and rotate so it pivots from one point.
Code:
const TO_DEGREE:Number = 180/Math.PI;
addEventListener(Event.ENTER_FRAME, rotateObject);
var maxRotSpeed:Number = 5;
var rotScale:Number = 0.2;
function rotateObject(e:Event):void {
[Code] .....
I'm trying to drag & rotate a planet so it spins around with the mouse -instance name: PlayerThe code works really well but it doesn't seem to rotate around the centre, instead it rotates from the top left corner.I'm quite a noob at as3 so I'm not quite sure where I've gone wrong with my code to be able to fix this. Do I need to specify the dimensions of the stage or the planet? I have altered the Stage from the the default 550 x 400 (if this could be the problem).
ActionScript Code:
import flash.events.MouseEvent;
import flash.events.Event;
[code].....
Been working on this for days and can't quite get it. Place a standard playing card or something similar on your desk in front of you. Lightly press your finger onto a random point on that card and drag it around your desk. See how it rotates towards the direction you are moving and such? I want to simulate that behavior.
View 8 RepliesI want to add in a menu bar at the bottom of the gallery. Meaning to say, all the photos that load up from the XML will be behind the menu bar. I tried with creating a new layer on top of every other things (inserted a rectangle box for testing), but the photos for the gallery comes infront of my rectangle box.
View 2 RepliesIm building a game, where the user has several images as movieclips. He can drag them to an area of the stage, and selecting them, he could rotate it. Does anybody knows some tutorials on hoe to start?
View 2 RepliesI'm trying to create a script that would imitate an old rotary phone dial. I have this script, but need it to function on MOUSE_DOWN:
Code:
handle.addEventListener(MouseEvent.ENTER_FRAME, startRotate);
function startRotate(e:Event):void {
var dx:Number=mouseX-handle.x;
var dy:Number=mouseY-handle.y;
// presupposes position of object to be facing to the right.
var radians:Number=Math.atan2(dy,dx);
handle.rotation=radians*180/Math.PI;
var hR:Number = Math.round(handle.rotation);
rotationA.text = String(hR);
}
Changing the event handler doesn't work. Somehow the MouseDown function should be working like an EnterFrame event, I guess. The condition I want to check is whether or not the handle is at a certain degree angle to stop the dial from rotating.
if (handle.rotation >= 30) {
handle.rotation = ?;
}
Not sure what I need to put in there to stop it from rotating.
I am stuck at the mo trying to create an interactive clock. I have got it to do everything, I would like the user to be able to drag and rotate the clocks hands clockwise 360 degrees.. ive got the hands to rotate by themselves what do i need to do?
View 5 RepliesI'm trying to create a navigation system that relies on the user dragging on a wheel in order to rotate it into a specific position: [URL]. The problem I have is that whenever a drag is initiated, the wheel jumps to a position where it points the zero-rotation point (indicated in the example by the red dashline) at the mouse direction. Whenever the drag is ended, the wheel stays at the position where the mouse has left it, which is correct.
However, when another drag is initiated, the same thing reoccurs - the dashed red line jumps to point towards the direction of the mouse. In short, I need the wheel to drag/rotate directly from the position where it was previously left or where it is by default. It shouldn't matter from which position the user drags the wheel. The code is located in the script of the wheel-movieClip, and is as follows:
Code:
onClipEvent (enterFrame){
this.onPress = function(){
// when the mouse presses on the wheel
this.onMouseMove = function(){
// get an angle to the mouse using atan2 (gets radians)
var angle = Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
[Code] .....
How to implement it so that the wheel rotation is independent from the position of mouse, while it is dragged.
I'm trying to create a navigation system that relies on the user dragging on a wheel in order to rotate it into a specific position:
[URL]
The problem I have is that whenever a drag is initiated, the wheel jumps to a position where it points the zero-rotation point (indicated in the example by the red dashline) at the mouse direction. Whenever the drag is ended, the wheel stays at the position where the mouse has left it, which is correct. However, when another drag is initiated, the same thing reoccurs - the dashed red line jumps to point towards the direction of the mouse. In short, I need the wheel to drag/rotate directly from the position where it was previously left or where it is by default. It shouldn't matter from which position the user drags the wheel.
The code is located in the script of the wheel-movieClip, and is as follows:
ActionScript Code:
onClipEvent (enterFrame){
this.onPress = function(){
// when the mouse presses on the wheel
[code]....
I can see how lacking the code is, and I can see why it does what it does. I just can't figure out how to implement it so that the wheel rotation is independent from the position of mouse, while it is dragged.
I have built this, drag the various dots.[URL]...%20parent.html I did not use the flash startDrag because it had all sorts of issues. I wanted the dots to be restricted to the stage when dragged. That is any dot CAN leave the stage when it is not the one being dragged. For example make the kite big and drag the red dot, the blue dots are free to leave the stage (marked by outline in the online example) The code I have uses mousemove, and some globalToLocal conversion to keep the dots from leaving the stage area All was well so far.
Now I find out the kite has to be able to rotate! when I simply rotate the kite all of my dragging rules break down. Click the big blue button, each click rotates the kite 5 degrees. Looks OK at first, rotate 30 or 40 degrees and everything breaks down. I know its the globalToLocal limiting, is there a better way? Seems people here have a lot of experience with dragging and rotating in flash. Does anyone see a way to fix what happens, or a whole new way to do the drag.
[Code]......
I have a round movieclip ( like a ring or clock ) and i want to press and drag it to rotate it around it's center ( AS3 ). I tried hundreds of ways but none of them works perfectly. I think i miss something in trigonometry and flash's rotation concept.
View 8 RepliesI have this problem...no worries it is only about ActionScript! I have created two movieclips: one is called "sun_mc" (with a nice smile) and a ring of sunrays (short and long ones) called "ring_mc".the ring is situated around the sun.
The user clicks the sun and drags to rotate it.The user can click the ring to rotate that too.When the sun is rotating...the ring should not be...and vice versa.
I have three problems...
1) I can't get the two mc's to move independently 2) When rotating the mouse position always jumps to a certain point on the movieclip...not the point where you clicked it first 3) The ring is also rotating when the mouse is outside the ring...
What should I do?I tried to obscure a part of the ring_mc with some masking...That didn't work.Should I try hitTest? And how should I do that? That only works with squares doesn't it?
[Code]...
okay, so i have a prototype for drag and rotate:
Code:
MovieClip.prototype.drag = function() {
this.i = 0;
this.ease = 10;
this.onPress = function() {
[Code...
now my problems. 1) without the doubleclicking, i need to click once on the movie clip to "activate" it or something, and then click again to drag it. shouldn't it work right away on the onPress event? and 2) i would like to add some doubleclick functionality, but when i try and add a double click, i can trace it, but if i try to do anything with it, the doubleclick functionality seems to be overridden by two single clicks ... logically, because i didn't check for the doubleclick at all in the drag script. i'm not sure where i should add the doubleclick stuff... i've tried putting it a few different places and either i get two single clicks, or my scope is way wrong and i wreck the drag stuff.
I need to rotate a drag and drop object 360 degrees. I've got the drag and drop working fine, but I could only figure out how to rotate it 4 times using the set property and arrow keys on the key board. Is there another action I can use to rotate it 8 times at 45 degree angles, or will I have to use the go to action and make 8 frames for the object? I would like to be able to rotate it by pressing just one key on the key board.
View 2 RepliesI am learning AS3 and trying to get an object to be able to move / rotate / scale and drag and drop. I found 2 seperate tutorials one does button clicks to move and rotate code.[code]When I add the second lot of code to the first app (ie add a layer and insert the script ) change myPoint to rocket . I get the following errors:'{' expected
View 1 RepliesMy project is to allow web visitors drag furniture onto a floor plan. I need the items to all be independent of each other with the drag and drop and then be able to rotate each item with a keyboard arrow.
The code I have allows all to drag and drop but I can only get the code to rotate one item. My Action Script 3 code follows:
[Code].....
My question is, is it possible to rotate an object from frame x to frame y?I mean, let's say I want to move an arm. Instead of working frame by frame to make it move, is it possible to somehow make it rotate 90 degree from let's say frame 10 to frame 15?
View 2 RepliesI'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.
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 RepliesI 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.