Drag and Rotate

Hi all,
i'm working on a projekt, which is a card game and i need to
implement some kind of rotation function.
Actually i can drag, pick up and drop the cards.
Now i want the cards to rotate depending on the movement of
the users mouse when he drags a card.
I tried to do it on my own but i can't figure it out.
As an example of what i mean check this link please:
Thibaud.be
I don't need a complete solution but an advice or a link to a
tutorial that deals with this kind of problem would be very nice.
Thank you very much.

open flash, create a new actionscript file and paste the code
that's below the dotted line into the as file and save as
regPoint.as in the same directory as your project files.
in your project fla attach the following to a frame

Similar Messages

  • Drag and rotate with multi touch

    i want to drag and rotate an imageview by using two fingers which will make the image look like a real object. I am able to move and rotate it,but at different time. I want to do it simultaneously. i think this can be done by calculating the angle between touches and then deciding the gesture and move and rotate accordingly. But can make out how to do it?
    Thanks for the reply.

    open flash, create a new actionscript file and paste the code
    that's below the dotted line into the as file and save as
    regPoint.as in the same directory as your project files.
    in your project fla attach the following to a frame

  • Mouse drag and rotation

    How do I rotate an object with the mouse after I have dragged the object with mouse. Essentially, 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.

    The problem arises due to the CLICK event being determined by the combination of a MOUSE_DOWN event followed by a MOUSE_UP event.  So your CLICK event occurs as soon as you release the drag.  You need to pull assigning the CLICK event out of the dragging scene altogether., otherwise it will be triggered.  One way to do that is to have two clicking functions at work for you.  One that uses the click that registers from the dragging to initiate the listener for other that deals with the rotation.  Here's one way to code it... it removes listeners once they have served their purpose...
    graybox.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    function pickUp(event:MouseEvent):void
          event.target.startDrag(true);
          graybox.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
          graybox.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function dropIt(event:MouseEvent):void
          event.target.stopDrag();
          graybox.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
          graybox.addEventListener(MouseEvent.CLICK, addClick);
    function addClick(event:MouseEvent):void
          graybox.removeEventListener(MouseEvent.CLICK, addClick);
          graybox.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
         event.target.rotation+=5;
         graybox.removeEventListener(MouseEvent.CLICK, onClick);
         graybox.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    graybox.buttonMode=true;

  • Having Problem Adding to drag and drop to move furniture over a floor plan

    I have the code which follows. I need to create floor plans where web visitors can drag and drop furniture onto the floor plan.  I have  three items that work but when I convert any additional items to a symbol and select movie clip and then add more lines to the code, none will work.. How can the code determine that  my movie clip I named "couch" is going to movie clip 4.  Thank you if you can help, Frankie Foster
    Below is my code:
    var numObjects:uint = 3  // assign the total number of movieclips that will be dragged
    for(var i:uint=1; i<=numObjects; i++){
         this["movieClip_"+String(i)].addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
         this["movieClip_"+String(i)].addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    var selectedMC:MovieClip;
    movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_2.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_3.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_1.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    movieClip_2.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    movieClip_3.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    function clickToDrag(event:MouseEvent):void
         selectedMC = MovieClip(event.currentTarget);
         selectedMC.startDrag(); 
    function releaseToDrop(event:MouseEvent):void
         event.currentTarget.stopDrag();
    stage.addEventListener(KeyboardEvent.KEY_DOWN, nextQuestion);
    function nextQuestion(event:KeyboardEvent):void {
          //trace(event.keyCode);
          if(event.keyCode == Keyboard.RIGHT)
               selectedMC.rotation += 5;
          if(event.keyCode == Keyboard.LEFT)
               selectedMC.rotation -= 5;

    Your appear to have redundant coding assigning your listeners.  What code are you trying to add/modify to make the couch function like the others?
    this...
    for(var i:uint=1; i<=numObjects; i++){
         this["movieClip_"+String(i)].addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
         this["movieClip_"+String(i)].addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    currently does what this also does....
    movieClip_1.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_2.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_3.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_1.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    movieClip_2.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
    movieClip_3.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);

  • Drag and Drop disappear issue

    Hello, I'm making a game in which I have some drag and drop items that they can be multiplied as many as you want. This items have to stay in the scene and I also have a bin in the menu where If you drag them they have to disappear.The problem is that I tried with multiple coordinates and they disappear also in the scene in the moment that I'm dragging them out of the menu. So, my question is:What could be wrong? Is the issue in the code?
    Thank you for taking the time to help me. It's my first game in AS3 so I'm not so familiar with the codes.
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    DDB1.addEventListener(MouseEvent.MOUSE_DOWN, createDDB1);
    var _DDB1:Sprite;
    function createDDB1(evt:MouseEvent){
      _DDB1 = new DDB1MC();
      _DDB1.x = evt.stageX;
      _DDB1.y = evt.stageY;
      _DDB1.rotation = evt.currentTarget.rotation;
      _DDB1.transform.colorTransform = evt.currentTarget.transform.colorTransform
      addChild(_DDB1);
      _DDB1.startDrag(false);
      _DDB1.addEventListener(MouseEvent.MOUSE_DOWN, dragDDB1);
      stage.addEventListener(MouseEvent.MOUSE_UP, dropDDB1);
    function dragDDB1(evt:MouseEvent){
      evt.stopPropagation();
      _DDB1 = evt.currentTarget as Sprite;
      _DDB1.startDrag(false);
      stage.addEventListener(MouseEvent.MOUSE_UP, dropDDB1);
    function dropDDB1(e:MouseEvent):void {
      _DDB1.stopDrag();
      stage.removeEventListener(MouseEvent.MOUSE_UP,dropDDB1);
      if (_DDB1.x>700 || _DDB1.x < 755 || _DDB1.y < 240 || _DDB1.y > 155) {
      _DDB1.removeEventListener(MouseEvent.MOUSE_DOWN, dragDDB1);
      _DDB1.parent.removeChild(_DDB1);
      _DDB1 = null;

    Chances are that the problem lies in the following line:
      if (_DDB1.x>700 || _DDB1.x < 755 || _DDB1.y < 240 || _DDB1.y > 155) {
    That line essentially says if(the object is anywhere) due to using the OR ( || ) operator.  If any one of those things is true then the condition is satisfied, which becxause they overlap will always be true for at least two of them.  If that is supposed to be restricting the object to within an area you likely want to all of those conditions to be satsified.  So in that case you need to use the AND operator ( && ).

  • IPhoto file creation date inconsistencies during drag and drop

    I have noticed that if I drag and drop a photo from iPhoto to Finder, the file creation dates in Finder are inconsistent.
    (This question is related to drag and drop only and not File->Export, which always uses the export date and timestamp for the file creation date and thus does not suit my needs).
    TEST A -- If the EXIF DateTimeOriginated is 01/01/2013, and today's date is 03/03/2013, then:
    In some cases when I drag a file to Finder, the EXIF date is used as the file modification/creation date in Finder
    In some cases, today's date is used as the file modification/creation date in Finder
    In some cases, a date in between the EXIF date and today's date is used
    It appears that for case A1, these are files that do not have a modified copy.  That is, if you select the photo in iPhoto and then click "File" -> "Reveal In Finder", the "Modified File" choice will be greyed out.
    For cases A2 & A3, iPhoto has inexplicably decided to create modified versions of these files either today or sometime in the past.
    TEST B -- I have read that unexplained modifications are tied to the auto-rotate function in cameras, and it does seem to be the case when I performed the test below:
    Select a large group of landscape format photos (these would not have been auto-rotated), then drag and drop to Finder.  The file creation dates are set to the EXIF date
    Add some portrait photos to the group in (1).  Now the file creation date of ALL photos including the non auto-rotated photos are set to the current date
    The behaviour in B2 is clearly wrong, since the landscape photos should be the same as in B1.  This is bug #1.
    Furthermore, iPhoto appears to be inconsistent with when these modifications are made.  For example, I dragged & dropped an auto-rotated photo on 02/02/2013, then dragged & dropped it again today, then the file creation date in Finder (and also the date of the modified file in iPhoto, as shown in iPhoto File->Reveal In Finder->Modified File) can either the EXIF date (01/01/2013), the late of the last drag & drop (02/02/2013), or today's date (03/03/2013); there does not appear to be any rhyme or reason to this.  This is bug #2.
    In any case, saying "you should never use drag & drop in iPhoto" (as I have read in some other forum posts) isn't a solution, because Apple should either (a) support this function correctly or (b) remove it altogether.  Furthermore, I regularly burn photos to disk for others so having the file date and timestamps correctly set to the EXIF date helps keeping the photos sorted in the directory listings for multiple OS, so File->Export isn't a solution.

    File data is file data. Exif is photo data. A file is not a photo.  It's a container for a photo.
    When you export you're not exporting a file. You're exporting a Photo. The medium of export is a new file. That file is created at the time of export, so that's its creation date. The Photo within that file is dated by the Exif.
    There are apps that will modify the file date to match the Exif.
    The variation you're seeing is likely due to the changes in how the iPhoto library works over the past few versions. Drag and drop is handy, but is not a substitute for exporting, nor intended to be.

  • Possible to creat a group of 3d objects and rotate each based on group's axis?

    I need to create an extruded rectangle.  On the face of that rectangle needs to be another extruded rectangle.  I'd like to be able to rotate both seperate objects in 3d based upon the same axis.  Is this possible?  I've played around with the 3d effects and cant seem to get this to work.

    An alternative can be: Make one rectangle and apply the Extrude effect. Drag it in the Symbols panel so as to make it a Symbol. Now draw another rectangle and apply the Extrude effect. In the Extrude dialog, use Map Art to map the symbol (of extruded rectangle).
    If you want to rotate them both along the same axis, either open the Appearance panel and change the already applied Extrude effect to rotate , or,
    Edit the symbol and rotate as required (this will reflect in the the whole doc) and rotate the another rectangle separately using Rotate tool.
    I hope it helps.

  • How do you make an object draggable without creating a drag and drop quiz question?

    I'm trying to make objects that can be dragged, scaled, and rotated by the user (not a preset animation).  Any way to do this?

    The only thing that comes to mind is a widget.
    If anyone would have it, it would be Rod Ward.
    Click here to visit the site and see the list
    Cheers... Rick

  • GC.log File Size Limitation and Rotation

    Hi,
    Is it possible to limit the size of a GC.log file and to rotate it without causing havoc?
    Best regards,
    Katzensee

    James Roller1 wrote:
    You say, if you use 1024 x 768 images... that's just it: I'm just using the images without resizing. Some may be 4MB files when dragged in; others may be 300kb. I am not doing anything to them. Should I?  Does that help? Or does IBA "handle all that" when I drag and drop?
    It's not well documented. I get the impression that, if you drop an image that has resolution higher than 2048 x 1536, it is down-sampled to that size. You should at least crop the image outside IBA before dropping it in. If you want to save space, down-sample the image first to 1024 x 768 (after cropping).
    James Roller1 wrote:
    Also for the video: we're using iMovie and we just "Share" to iTunes and choose Large. Should I be choosing a lower setting or, again, does IBA not care and will take the Large and resize it?
    Instead of sharing to iTunes, export the movie to iPad format (File -> Export) and select 640 x 480. That'll give you reasonable quality at around 12 MB per minute.
    James Roller1 wrote:
    I have to say I chuckled at the wisdom and simplicity of the 2 Volume suggestion. I'd like to keep it as one, and I'd like to sell it on the store, but your idea is ingenious in its simplicity: just make 2!
    Thanks! Two's better'n one
    Michi.

  • I want to Sync my iPhone 4 to iTunes however I get an error message from iTunes each time I connect the phone to the PC saying that I should restore to factory settings. Frustrating because it's already annoying enough that I can't drag and drop mp3's!!!

    I have never been so frustrated before in my life with any phone. I find it obnoxious as it is that I cannot simply drag and drop files (especially MP3's) straight from my PC directly into my phone, which I have been used to doing up until now. Everyone who convinced me to get the iPhone has instructed me that my frustration can be fixed by downloading iTunes and syncing it all up via that program (which I have never used before). So, I downloaded the program successfully, however when I connect the iPhone 4 to the PC and iTunes is open, I get an error message that 'iTunes cannot read the content of the iPhone "iPhone" and that I should go to the Preferences tab of the iPhone and select 'restore' to restore this phone to factory settings. First of all, I don't understand why I need to do that. I have already downloaded apps and other important things in the 2 days that I have the phone. I am also scared that it will erase my contacts. This is such a headache. Music is very imporatant to me, but I am getting so frustrated that I don't have freedom over the phone which I thought was supposed to be one of the best out there. I would really appreciate help in this matter. I am sure the phone is great but I am on the verge of taking it back and getting something else.

    Hey joshuafromisr,
    If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/HT1925
    or here:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Best,
    David

  • When I drag and drop an icon from the address bar to the desktop is does creat the shortcut but will not display the website icon, only the firefox icon, how can I display website icons?

    When I drag and drop a website icon from the Forefox address bar to the desk top, the short cut is created but the icon that appears is the firefox Icon. I want to disply the icon from the website that the short cut refers to. I have checked all I can think of in my computer to no avail.

    You have to assign the favicon yourself to the desktop shortcut (right-click the shortcut: Properties) after you have dragged the link to the desktop.
    You can usually find the favicon in Tools >Page Info > Media and save the icon there.
    Otherwise use the main domain of the website and add favicon.ico (e.g. mozilla.com/favicon.ico ) to display the favicon in a tab and save that image to a folder.

  • Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?

    Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
    This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
    If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
    Thankyou
    Andrew.

    Andrew,
    Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
    No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
    If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback.

  • Why does not drag and drop work?!

    Hello,
    I am trying to implent a drag and drop from a table to an icon representing a trash.
    The drop handler fails in converting the selected rows to a list:
    com.sun.el.MethodExpressionImpl@87d9c00d javax.el.ELException: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
    Could you help me to understand why? Below are the details.
    This is the af:table:
    <af:table var="row" rowBandingInterval="0" id="t1"
    value="#{bindings.MyView1.collectionModel}"
    rowSelection="multiple"
    columnStretching="last"
    horizontalGridVisible="false"
    verticalGridVisible="false" fetchSize="-1"
    autoHeightRows="6" width="190"
    disableColumnReordering="true">
    <af:column sortable="true" headerText="Entry" id="c1"
    align="start">
    <af:outputText value="#{row.Description}" id="ot1"/>
    </af:column>
    <af:dragSource actions="MOVE" defaultAction="MOVE"
    discriminant="delete"/>
    </af:table>
    This is the drop area:
    <af:image source="Images/empty_trash_32.png" id="i2">
    <af:dropTarget dropListener="#{backingBeanScope.DropHandlerBean.dropHandler}"
    actions="MOVE">
    <af:dataFlavor flavorClass="org.apache.myfaces.trinidad.model.RowKeySet"
    discriminant="delete"/>
    </af:dropTarget>
    </af:image>
    This is the failing listener listener (the failing point is bold):
    public DnDAction dropHandler(DropEvent dropEvent) {
    DnDAction dnda = DnDAction.NONE;
    if (dropEvent.getProposedAction() == DnDAction.MOVE) { // delete
    RichTable table = (RichTable)dropEvent.getDragComponent();
    //determine the rows that are dragged over
    Transferable t = dropEvent.getTransferable();
    //when looking for data, use the same discriminator as defined
    //on the drag source
    DataFlavor<RowKeySet> df =
    DataFlavor.getDataFlavor(RowKeySet.class, "delete");
    RowKeySet rks = t.getData(df);
    if (rks == null) {
    return DnDAction.NONE;
    Iterator iter = rks.iterator();
    while (iter.hasNext()) {
    //get next selected row key
    System.out.println(rks.toArray().length); // the number of selected rows is ok
    List key = (List)iter.next(); // here gives: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
    //make row current so we can access it
    table.setRowKey(key);
    //the table model represents its row by the ADF binding class,
    //which is JUCtrlHierNodeBinding
    JUCtrlHierNodeBinding rowBinding =
    (JUCtrlHierNodeBinding)table.getRowData();
    Row row = (Row)rowBinding.getRow();
    //delete row;
    row.remove();
    //activate animation
    dnda = DnDAction.MOVE;
    return dnda;
    thanks.

    I did try, I obtained this:
    java.lang.NullPointerException
    Why NullPointerException?
    I don't know if this helps, but consider that the collection model comes from a ViewObject built on three EOs with many fields, although the table only shows one column.
    This is the Iterator in my pageDef:
    <table IterBinding="MyView1Iterator" id="MyView1">
    <AttrNames>
    <Item Value="Cod1"/>
    <Item Value="Cod2"/>
    <Item Value="Cod3"/>
    <Item Value="Cod4"/>
    <Item Value="Description"/>
    <Item Value="Cod5"/>
    </AttrNames>
    </table>
    Any idea?
    I will see the Key content with the debugger.

  • Did my first back up today using external hard drive and time machine now i can't drag and drop

    Hi, i did my first back up today using time machine it all went onto my external hard drive fine. Now i cant drag and drop anyhting. I assume ive cahnged some settings in time machine but cant figure it out what to do can some one help ?
    thanks

    Brandbasher wrote:
    Thanks Pondini but i have closed time machine, removed external hard drive.
    Did you eject it first?
    Now i cant drag and drop anything on my desk top, or mail or any other application. Ive tried moving folders, documents none of it works. Even moving around documents within a folder, it wont let me chnage the position of files.
    That shouldn't be related to Time Machine (especially if the backups aren't mounted).
    What happens when you try those things?  Do you get any messages?  Anything you can post a screenshot of?
    Have you tried a Restart?
    Does it happen in another user account?  (If you don't have one, create one via System Prefs > Users & Groups.)

  • Drag and Drop (re-order) Thumbnails in Organizer

    I am using Photoshop Elements version 5.0.2
    I would like to re-order pictures in an order that will make sense for me in my business. I suppose I can go through each pix and change the time on them, so I can then sort by time stamp.
    Is there an easier way to do this? I was hopeful that I could drag and drop them in Thumbnail view - but I cannot.
    Thank you,
    Jamie

    >Is there anyway to delete the photos in the main well, without losing them from my collection?
    As I understand the design, the main well is intended to be all the photos that you are managing with Photoshop Elements.
    Collections are used to display a specific group of those photos in your chosen sequence for any given activity.
    I suspect that since you are using a consumer product such as Photoshop Elements for your business purpose, you may need to make some compromises like having a default (the main photo well) display sequence which you see first when starting PSE that is not what you would choose.
    This is not bad if PSE does what you want - just additional steps to switch to the Collection view and also to maintain (drag and drop) the sequencing of the collection when you add additional photo files to a Collection.

Maybe you are looking for

  • Custom Workflow Load Error in Power Center error code 36331

    Hi, I have installed OBIEE version 11.1.6 and OBI APPS version 7.9.6.3. I am using informatica power center 9.0.1. I have followed the following guide Oracle® Business Intelligence Applications Configuration Guide for Informatica PowerCenter Users Ve

  • Report painter year characterstic

    Dear Experts, I need to develop a report thru report painter 2010           1     12                          2009           1     12 2008           1     12 For the above i need actual and plant 2011            1     12 2012            1     12 For

  • Why can I only see the background?

    I recently trie changing the resolution on my MacBook Pro, when it didn't work I did an NVRAM reset, this has now caused my useable window to disappear and all I can see is the background. I have no side bar, no bar at the top of the screen, nothing

  • Performance Manager slices ans chart thermometer

    i have a analytic with slices, and that the user can choose navigation between slices, more in my chart thermometer the slider does not change, how do i solve this problem? thank you Edited by: gzofera on Sep 16, 2008 10:13 PM

  • I buy a year scrip for illustrator, and when it finished installing and setting up it said i only started my 30 day trial.

    Why is this? can it be fixed i have the billing confirmation for the first months payment and everything.