Rotate the matrix of the position of the mouse.

Hey guys I've been banging my head against this problem for a few hours.  I have a rectangle object created, I want that the rotation of the rectangle following my mouse cursor. (I am easily able to do).  Where things become difficult, is that I want the rectangle to turn around its lower right, for this I found that I need to use a transformation matrix.  At this point, I am able to have my rectangle revolve around the bottom to the right of point, but I can not understand how to follow my mouse cursor as well during rotation.  The reason being that with a matrix you can only say to him a quantity of radians to rotate (matrix.rotate) rather than only being able to define his current rotation... Here is my code

point: var Point = new Point (myRectangle.x+myRectangle.width/2, myRectangle.y+myRectangle.height/2);

function rotateObject (event: Event): void

{

var m:Matrix = myRectangle.transform.matrix;

m.TX = point.x;

m.Ty = point.y;

m.Rotate (45 *(Math.PI/180));

m.TX += point.x;

m.Ty += point.y;

myRectangle.transform.matrix = m;

}

addEventListener (Event.ENTER_FRAME, rotateObject);

So with the current code, it runs constantly in the lower right, I have tried to change the '45' to ' Math.atan (mouseX/mouseY), but there again, it seems that only works if I could set the rotation of the matrix which, rather than say how things to spin to...»

Any thoughts or ideas would be appreciated, thanks!

Sure... Create a new AS3 document, paste this into frame 1, run:

import flash.geom.Rectangle;

import flash.display.Sprite;

import flash.events.Event;

container, I use graphs and draw

directly to this

var container: Sprite = new Sprite();

addChild (container);

draw the rectangle, pushing upward on the axis y

container.graphics.beginFill(0xFF0000,1);

container.graphics.drawRect (0, -100, 100, 100); See the-100 on the y-axis?

container.graphics.endFill ();

Place it in the center of the stage

Container.x = stage.stageWidth / 2;

Container.y = stage.stageHeight / 2;

start shooting baby

addEventListener (Event.ENTER_FRAME, rotateMeBaby);

function rotateMeBaby(e:Event):void

{

Container.rotation += 3;

}

Tags: Adobe Animate

Similar Questions

  • The mouse wheel will only up to?  Bridge (Photoshop CS4)

    I am facing a problem with Bridge (CS4) where the mouse wheel scrolls only upward.   Any attempt to scroll down causing the erratic behavior.   If you scroll at a normal speed, it always returns to the top.  If you rotate the mouse toward the low fast roulette, bridge is going through some then go up a little.   No problem in any other product such as Photoshop CS4 Adobe.

    Has anyone reproduces this behavior?

    Any solution?

    NOTE: WACOM Tablet mouse works correctly.

    Kind regards

    Valerie

    I had the same problem until I downloaded the 64 bit Windows 7 drivers of

    http://www.Microsoft.com/hardware/download/download.aspx?category=MK&type=mouse&SKU=QVA-00 001

    .

    Pablo

  • How to get a picture to rotate the position of the mouse in the Muse?

    Hey guys,.

    I'm a home page that is centered around a logo design. I need the logo to turn around 360 degrees as the mouse explores the area around him. I enclose a pochade explaining the type of movement that I need, a model of what the page might look like, and a .png file I use for the logo. Please give detailed instructions, as I am a bit new to Muse. Thanks in advance, any help is MUCH appreciated!

    Wirelos Website Sketch.jpg

    Wirelos-Logo-Example.png

    Home Page1.jpg

    UPDATE: the movement can be done very simply in Adobe Edge animate the following procedure:

    (and then published as a Deployment Package animate and inserted in the Muse in a .oam file).

    "Based on that response stack Exchange Edit fiddle - JSFiddle .

    Place the script provided in compositionReady and change the img var name of your item reference.

    example: var img = sym.$("WirelosLogoTight");     "

    -Heathrowe

    Hope this helps someone else with the same question. Here is a link to this post: How to create an animation that runs in response to the mouse position?

  • somehow my screen turned completely sideways, how to rotate the screen back to normal?

    somehow my screen turned completely sideways, how to rotate the screen back to normal?

    Use the Ctrl key or the Alt key with the arrow keys to rotate your screen to its normal position. You can also right-click an empty space on your desktop and in the context menu that appears look for the rotation of the screen, orientation, landscape, or something similar.

    Kind regards

  • Type of area tool AND able to rotate the text... is this possible?

    Hi people,

    Could someone please tell me if its possible, and if so, how can I add text to a triangle where the text is rotated 90 degrees to the right?

    I know that adding text via the area type tool it fits to the triangle, however when I then try and rotate the triangle (thinking that this would turn the text with it) the text remains in its original position and wraps simply to accommodate the movement of the triangle encompassing.

    If I use normal type tool, I can then turn the rectangle type area to have the text in the right direction, I need... the problem is it is a rectangle and does not match the shape of triangle.

    I feel so close and I'm sure its something simple, but I just can't cope. TIA

    See you soon

    Beth

    Hi Beth,

    Please see the link below to learn how to rotate text in artificial intelligence:

    How to scale and rotate type in Illustrator

    Kind regards

    OM

  • Follower of the mouse of rotation with easing

    I'm terrible at math and having a problem to reach my goal.

    http://www.newgrounds.com/dump/item/6e5cde6c6b94de74119aac82c43312d2 - example

    It works just fine, but what I want to do is have each object to follow the rotation at different speeds. I want that every MC having "Acceleration".

    I can't understand how to run a little slower than the mouse itself. As a result, just dead on, same speed as the mouse moves, it moves.

    Related to mcMouseFollower.as MovieClip class.

    I have my main class the following:

    package {}

    import flash.display. *;

    import flash.events.Event;

    SerializableAttribute public class MAIN extends MovieClip {}

    public var follower: mcMouseFollower;

    public void MAIN () {}

    the constructor code

    Tracker = new mcMouseFollower();

    Follower.x = stage.stageWidth / 2;

    Follower.y = stage.stageHeight / 2;

    stage.addChild (follower);

    stage.addEventListener (Event.ENTER_FRAME, frameLoop);

    }

    public function frameLoop (event: Event): void {}

    Check out the coordinates of the mouse to discover the angle

    var cy:Number = stage.mouseY - follower.y;

    var cx:Number = stage.mouseX - follower.x;

    var Radians: Number = Math.atan2 (cx, cy); / / Find the angle

    var degrees: Number = Radians * 180 / Math.PI;// convert to degrees of rotation

    Rotate

    Follower.rotation = degrees;

    }

    }

    }

    To do this manually, you need to find the change in rotation between the follower.rotation and the degrees of calculated. Then, you apply some of this difference. So if you want to have the rotation of the rod move 1/10 of the path to the destination of your choice each image, calculate the change in the rotation needed to point to the mouse, then multiply by 0.1 and apply this rotation changed to follower.rotation. This does not exactly work as tweens that you configure in Flash because it will not have an exact end time. Instead, each image rotation reduces the difference in new rotation of half. It will resemble an ease of exit. You can check when it is thin enough (for example, the difference is less than 1 degree) and just snap to your final rotation rather than continue to settle for halfway.

    You'll want to know how to work the degrees of rotation. Pointing to the right is 0 degrees, rotation to the right there is positive, go to 180 that points to the left. From 0 degrees and rotating timer causes the downward rotation value, entering negative numbers, from 0 to-180 (pointing to the left). So when you try to interpolate a value through the left direction you have a problem, since the numbers of jump from-180 to 180 at that time here.

    To solve this * West * problem, you detect if the rotation must be changed by more than 180 and you adjust accordingly for the direction of rotation moves the shortest distance to the rotation of the target rather than the long way around. The calculation in the SmartRotationPlugin of the packaging of GTween is a good way to handle this:

    https://code.Google.com/p/Pipoca/source/browse/trunk/classes/com/gskinner/motion/plugins/S martRotationPlugin.as? r = 9

    Here's the corrected code (starting after your calculation of degrees):

    var deltaDegrees:Number = degrees - follower.rotation;

    deltaDegrees % = 360;

    If (deltaDegrees > 180)

    {

    deltaDegrees-= 360;

    }

    ElseIf (deltaDegrees<>

    {

    deltaDegrees += 360;

    }

    Rotate

    Follower.rotation = degrees;

    Follower.rotation += deltaDegrees * 0.1;

    You can also consider using a tween as GTween for your tween engine: http://www.gskinner.com/libraries/gtween/

  • Control a movieclip with the position of the mouse

    Hello everyone,

    I worked on a small project at work, I'm trying to controll a movieclip which consists of 60 still images of an aircraft (total 120 frames) that when played will show a view of 360 degrees of said aircraft. I can make it work with buttons, but ultimately I want to control the movieclip by moving the mouse. If anyone can help, that would be wonderful. Thanks in advance.

    Here is the code:

    import flash.events.MouseEvent;

    AC. Stop();

    stage.addEventListener (MouseEvent.MOUSE_MOVE, mouseMove);

    function mouseMove(event:MouseEvent):void
    {
    If (mouseX > 800 & & (mouseX < 1600))
    {
    ac.gotoAndStop (ac.currentFrame + 1);

    if(AC.currentFrame == 120)
    {
    ac.gotoAndStop (1);
    }
    }
    on the other
    {
    ac.gotoAndStop (ac.currentFrame - 1);

    if(AC.currentFrame == 1)
    {
    ac.gotoAndStop (120);
    }
    }
    }

    Using this code, the SWF file acts ok without error. I can do the movieclip play in any direction, however, when you move the mouse in the opposite direction that the movieclip continues to play forward or backward.

    Thank you

    Tommy

    There are at least two ways you can address this problem and they both require to control the position of the mouse more closely.  Now you have a general... If it's 800 > ahead and if his < 800="" step="" back,="" but="" when="" you="" step="" back="" from="" 1200="" to="" 1199="" you="" are="" still=""> 800, if you take one more step.  You need to either follow the change in mouse position or the position of the mouse to determine the framework of movieclip.  The second one is probably easier to design and will also be more accurate if the intention is to have a rotation for a displacement of the full scale of the mouse... otherwise you could just step back of a pixel at a time and in 120 pixels of movement... that might be what you want-the purpose is not explained in what you provided.

    (1) following the change of the position of the mouse - you must keep track of where the mouse was against where the mouse is when you check it... if(previousMouseX > currentMouseX)... you need to make the animation go back, etc...

    (2) with the position of the mouse to determine the frame movieclip - divide 120/1600... This is the number of images per pixel.  Take the current value of mouseX and multiply by that and make it an integer - go to this issue of image in the animation... simplifies this entire function similar to...

    function mouseMove(event:MouseEvent):void {}

    ac.gotoAndStop (int(mouseX*120/1600));

    }

    but refine to remember that there is no image 0

  • Rotate the symbol based on cursor angle

    Hey there,

    I'm trying to get a symbol of turn and follow based on the angle of the slider and I'm running into a problem that I can't find. I use sym to decalre my variables so that I can reference them in the world a few my composition. But it looks like its something wrong with the diffAngle function.

    Any thoughts?

    Here is the code on the composition of get ready:

    SYM.x = e.pageX;

    SYM.y = e.pageY;

    sym.centerItem = sym.getSymbol ("mySymbol");

    sym.centerLoc = centerItem.offset ();

    Console.log ("point Center =" + sym.centerItem);

    Console.log ("Center Loc =" + sym.centerLoc);

    function diffAngle() {}

    SYM. DX = sym.x - (sym.centerLoc.left + (sym.centerItem.width () / 2));

    SYM.dy = sym.y - (sym.centerLoc.position () .top + (sym.centerItem.height () / 2));

    sym.newAngle = Math.atan2 (sym.dy, sym.dx) * (180 / Math.PI);

    Return sym.newAngle;

    Console.log ("New Angle =" + sym.newAngle);

    }

    $('_#Stage').mousemove (function (e) {}

    sym.myAngle = sym.newAngle;

    sym.rotationValue = "rotate (' + sym.myAngle + ' deg)';"

    .CSS ({$("mySymbol") sym.

    ' - moz - transform ': sym.rotationValue,

    ' - webkit - transform ': sym.rotationValue,

    "- o - transform": sym.rotationValue.

    "- SM - transform": sym.rotationValue.

    "transform": sym.rotationValue

    });

    Console.log ("the mouse move '");

    });

    Hey there, your code has a few problems.

    1: use accessories such as "offset" and "width", you cannot use the Edge symbols, you must use the raw object - I use jQuery for this.

    2nd: you define the position of mouse reactive power (sym.x, sym.y), in the mousemove function.

    example:

    www.timjaramillo.com/code/edge/rotateSymbolToMouse

    Source:

    www.timjaramillo.com/code/Edge/_source/rotateSymbolToMouse.zip

    And the code (pasted in Stage.compositionReady):

    SYM.x;

    SYM.y;

    sym.myAngle;

    sym.newAngle;

    sym.centerItem = sym.$("mySymbol");

    sym.centerLoc = sym.$("mySymbol").offset ();

    function diffAngle() {}

    SYM. DX = sym.x - (sym.centerLoc.left + (sym.centerItem.width () / 2));

    SYM.dy = sym.y - (sym.centerLoc.top + (sym.centerItem.height () / 2));

    sym.newAngle = Math.atan2 (sym.dy, sym.dx) * (180 / Math.PI);

    Return sym.newAngle;

    }

    $('_#Stage').mousemove (function (e) {}

    SYM.x = e.pageX;

    SYM.y = e.pageY;

    sym.myAngle = diffAngle();

    sym.rotationValue = "rotate (' + sym.myAngle + ' deg)';"

    .CSS ({$("mySymbol") sym.

    ' - moz - transform ': sym.rotationValue,

    ' - webkit - transform ': sym.rotationValue,

    "- o - transform": sym.rotationValue.

    "- SM - transform": sym.rotationValue.

    "transform": sym.rotationValue

    });

    Console.log ("moving the mouse, sym.myAngle = ' + sym.myAngle");

    });

  • How to rotate the IPAD during installation (down key does not)

    Hi, I have an old 1st generation IPAD where the bottom 10% of the screen no longer works. I tried to reset the IPAD, but now I'm stuck on the screen "to accept the license. Is there a way to get around this? Can I rotate the screen at this time?

    Thank you

    Hi Icetbr,

    What a great iPad model you have there! If you already tried to change the orientation of the screen during the initial installation without success, then you will not be able to turn right there. But no worries. You may be able to activate the Zoom feature during the installation process that will allow you to access the agreement to license button. Also, given that you have problems with the display, you should consider having repaired to your Apple local store or service center. The steps and the links below will help you activate the Zoom feature as well as to get some great info to get your iPad repaired if you choose to.

    When you turn on your iPhone, iPad or iPod touch for the first time, you can quickly activate VoiceOver or Zoom for you help to set up your device. Here's how:

    Zoom
    To activate the Zoom, use three fingers and double-tap the screen.
    To increase the Zoom level, use three fingers to double - tap and hold, and then move your fingers upward or downward on the screen to increase or decrease the magnification.

    Use the accessibility features in iOS

    iPad Repair - screen damage

    Thank you for using communities of Apple Support. Have a great day.

  • Portege M780-106 - the mouse pointer position of the stylus trolling

    Question re Toshiba portege M780-106 touch screen laptop:
    We have a problem with the mouse, the position of the stylus trolling.

    This gap considerably increases the speed of the increase in movement of the stylus.
    As we had a task of monitoring with the stylus it is problematic.

    We run the task in Windows 7 using python 2.6 with mainly pygame library functions.
    Is there a way to disable the process that produces this discrepancy between stylus pointer and mouse?

    Any help much appreciated!

    Best
    Steve

    The CPU is running in performance mode? There may be a delay because the eco mode is activated, or the speed of the CPU has strangled at low speed.

  • My iPhone 6 s Plus the function to rotate the screen how this return

    My iPhone only more 6 used to rotate the screen, it is more the fact how this function returns

    Swipe up from the bottom of the screen to bring up the control center. Then press the icon that looks like a padlock inside a circular arrow. https://support.Apple.com/en-us/HT204547

    -AJ

  • Satellite L450 - Win7 how to rotate the screen?

    Hi guys please help

    I don't know what my 5 year old niece pressed during playback on this platform, but she managed to rotate the office upstairs on the right, so start it s on the side, ok on the post screen, tried the system restore, but it says a file is missing and could not complete this am of course has nothing to do with my little problem that's for later, thanks

    Hello

    I put t know if this will help but check please follow thread http://forums.computers.toshiba-europe.com/forums/thread.jspa?messageID=121049

    Please post comments.

  • Pre-sales question: how to rotate the old video files

    Hello, I can't find my answer via google.

    I would like to run some very old phone videos taken vertically, but horizontally play.  There are still more some video files vertical I want to compress to a more manageable size.  I have an older version of the compressor that does not work with Yosemite.  The new version will manage the videos for me?

    Thank you.

    N °

    I would use a NLE like final cut PRO, QUickTime Player, or MPEG Streamclip to rotate the clips.

    Good luck.

    Russ

  • Position of the mouse in a chain of control/indicator

    Hi all

    By using LabVIEW 2015 and would like to know if it is possible to do the following...

    I have a string with a paragraph or two of text.  In this text, certain words and phrases are highlighted (by different font color).

    I would sense when the mouse is positioned on one of these and change the type of cursor when it is over them.

    .. think of hyperlinks in a browser.

    I feel when I'm on the control of the chain itself, but not for specific text.

    Any ideas?

    Thank you!

    Charlie

    The string should contain a method that takes the coordinates (which you can get from a mouse event down or move the mouse) and tells you where it is in the string. Create a node to invoke for the string, and then select the method used (I think he called Point byte Offset). I don't have any experience with it, but I guess it compensates for things as sizes of scrolling and the police.

  • rotate the document

    I have a HP Officejet Pro 8600. When scanning I frequently neet to rotate a multi-page document. How to turn the entire document at once rather than on a single page at a time.  Sam Bear1

    Hello-

    You can rotate the document in two ways:

    1. for the use of our scan software, you can use the Rotate button (see below). However, this requires you to click on each page, then rotate. Then save.

    2. When you open the original document saved with Adobe Reader, click on the view button, then "rotate the view. This will transform documents. Then save under.

    I hope this helps.

  • Rotate the Plot chart legend of XY

    Is it possible to rotate the legend of the plot for the plot names letters run from the bottom to the top rather than in the whole of the operator interface?

    The names of my plots are bigger and I need to show at least four plots at the same time. Put the scales to the right/left/above or below without rotating can cause a short XY Chart!

    Any ideas for me?

    Concerning

    Waris K

    Hello

    I don't know if there is a native way to do it, but you can 'cheat' to do this:

    You can move the table where the captions are, or even make the table turn into lines instead of the column.

    Is the idea ok for you?

Maybe you are looking for