Having problem adding to drag-and - drop operation to move the furniture on a floor plan

I have the following code. I need to create floor plans where users can drag and drop the furniture on the floor plan.  I have three elements that work but when I convert all of the additional items to a symbol and select movie clip and then add several lines to the code, none work... How the code can determine that my clip I named 'couch' goes to clip 4.  Thanks if you can help, Frankie Foster

Here 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;
}
}

It is not a conflict, but it's a waste of code because they are both the same thing.  The first with the right loop is more effective in terms of coding and will make life easier for you because you only need to adjust the numObjects value to have it include more.

You just need to assign instance names for the rest of your objects in the same way... movieClip_ # code as you (with loop version) should be enough.

Tags: Adobe Animate

Similar Questions

  • cannot drag and drop a shortcut on the desktop of the address bar.

    I can drag and drop a shortcut to the menu of bookmarks. I can't drag and drop in the menu bookmark on the desktop. I can't drag and drop the address bar on the desktop.

    You drag the text selected in the address bar or the button "Site Identity" (lock/globe)?

  • Not able to drag-and - drop to import into the project

    Hello

    I'm simply is no longer able to drag and drop images to import the premiere pro cs6 project.

    (File is .avi created from Premiere Pro CS6, common parameters Media Encoder).

    Can someone help me with this?

    Windows 10

    Thank you very much, Bob, of the Peru.  That helped a lot.  It turns out that I had put Premiere Pro CS6 to run as administrator.

    Initially, I started first with the pressed-in shift (to reset preferences), but that didn't solve it.

    That's when I remembered, I tried 'run as administrator '.

    See you soon!

  • Drag and drop of MC to the other?

    Hello

    I created a bunch of MCs since a single MC in the library dynamically.

    Inside the timeline of the MC, I wrote drag and drop code.

    The MC is a parent movieclip, then residing in a scrollpane.

    I was wondering if it is possible to write AS3 to drag the clips into an another movieclip?

    If this isn't the case, the way I got it, is it at all possible to drag one MC container to another MC?

    Thank you

    Shaun

    You will need to create a new listener that monitors for MOUSE_MOVE which can constantly check the position of the cursor from whatever you intend to impose limits.  But the real test by you could be a little tricky to manage in terms of use of a hitTestObject approach since you can't test the object moved against its parent (because it in itself defines the limits of the parent).  You can optionally create another object within the parent that you test over hitTestObject using, maybe we you the alpha 0 for value so that you can't see.

    In all cases, the general approach would be something to the effect of...

    MC3.addEventListener (MouseEvent.MOUSE_DOWN, dragIt);
    function dragIt(evt:MouseEvent):void {}
    MC3.StartDrag (false);
    MC3.addEventListener (MouseEvent.MOUSE_MOVE, checkIt);
    }

    MC3.addEventListener (MouseEvent.MOUSE_UP, dropIt);
    function dropIt(evt:MouseEvent):void {}
    stopDrag();
    MC3. RemoveEventListener (MouseEvent.MOUSE_MOVE, checkIt);
    }

    function checkIt(evt:MouseEvent):void {}
    If (CONDITIONAL LIMITS OUTSIDE GOES HERE)) {}
    dropIt (evt);
    }
    }

  • How to prepare list for garbage collection after drag and drop operation

    Hi all

    I have a view in a mobile application that contains a list with the help of drag / move. The problem I encounter is that the NativeDragManagerImpl maintains a reference to this list in its _dragInitiator and _relatedObject properties. It is not a memory leak by - say, because the reference will be replaced the next time make drag and drop is used, however, my view that preclude any garbage collection, causing an unacceptable peak memory.

    Here is an example which illustrates the problem (app default AIR using Flex 4.5.1):

    Main.MXML

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:local="*"
                                                         xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" width="800"
                                                         height="600">
    
    
              <fx:Script>
                        <![CDATA[
                                  protected function start_clickHandler(event:MouseEvent):void
                                  {
                                            var element:ListGroup = new ListGroup();
                                            this.panel.addElement(element);
                                  }
    
                                  protected function stop_clickHandler(event:MouseEvent):void
                                  {
                                            this.panel.removeAllElements();
                                  }
                        ]]>
              </fx:Script>
    
    
              <s:Panel id="panel" top="100" left="100" bottom="100" right="100" title="Drag Drop Test">
                        <s:controlBarContent>
                                  <s:Button label="Start" click="start_clickHandler(event)" />
                                  <s:Button label="Clear" click="stop_clickHandler(event)" />
                        </s:controlBarContent>
              </s:Panel>
    
    
    </s:WindowedApplication>
    
    

    ListGroup.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
                         xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%">
              <s:layout>
                        <s:HorizontalLayout />
              </s:layout>
              <s:List id="sourceList" width="100%" height="100%" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
                        <s:dataProvider>
                                  <s:ArrayCollection>
                                            <fx:String>Item 1</fx:String>
                                            <fx:String>Item 2</fx:String>
                                            <fx:String>Item 3</fx:String>
                                            <fx:String>Item 4</fx:String>
                                  </s:ArrayCollection>
                        </s:dataProvider>
              </s:List>
              <s:List id="targetList" width="100%" height="100%" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
              </s:List>
    </s:Group>
    
    

    If you drag items to the list on the right, there is always at least one instance of ListGroup stuck in memory for the duration of execution (as seen in the profiler).

    Is there a way to perform cleanup on the DragManager (or in fact the underlying DragManagerImpl) upward to a time of my choosing? Thoughts or ideas will be greatly appreciated!

    Thanks a lot for your time!

    I think I'd be monkey-patch NativeDragManagerImpl.  And create a bug report.

  • Problem slider disappears / Drag and Drop does not work

    Hey everybody,

    I have an urgent problem.

    Three butterflies are supposed to be slipped into an object.  My custom cursor is a kind of net to catch these butterflies.


    For the cursor, I have this code:

    cursor_mc.StartDrag ("true");
    Mouse.Hide ();

    My drag and drop code is:

    cursor_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    redbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    violetbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    yellowbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);

    cursor_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    redbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    violetbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    yellowbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);


    function startMove(evt:MouseEvent):void {}
    redbutterfly_mc.StartDrag ();
    cursor_mc.StartDrag ();
    violetbutterfly_mc.StartDrag ();
    yellowbutterfly_mc.StartDrag ();
    }

    function stopMove(evt:MouseEvent):void {}
    redbutterfly_mc.stopDrag ();
    cursor_mc.stopDrag ();
    violetbutterfly_mc.stopDrag ();
    yellowbutterfly_mc.stopDrag ();
    }

    But when I'm clicking on a butterfly my cursor stops to move and stay on the throttle position, that I'm dragging. After a fall, there is no cursor at all so we don't know where the mouse is currently located.

    Anyone know why it does not work? I am currently working with a mousefollower, because right now, it's the only way it works...

    The mousefollower code is:

    addEventListener (Event.ENTER_FRAME, enterFrameHandler)

    function enterFrameHandler(event:Event):void {}
    cursor_mc.x += cursor_mc.mouseX / 4;
    cursor_mc.y += cursor_mc.mouseY / 4;
    }

    But now I have the problem that only the Yellow Butterfly moves even if I'm clicking on red or purple...

    Please help me! Thank you in advance!

    Try to use the following code to manage the cursor_mc...

    Mouse.Hide ();
    cursor_mc.mouseEnabled = false; keep the cursor to interfere
    this.addChild (cursor_mc); to place the cursor at the highest level

    function moveCursor(evt:MouseEvent_=_null):void {}
    cursor_mc.x = mouseX;
    cursor_mc.y = mouseY;
    }
    stage.addEventListener (MouseEvent.MOUSE_MOVE, moveCursor);

    moveCursor(); to locate initially mouseover

  • Cannot drag and drop a pattern to the color chart

    I have a PC with Windows 10 so maybe that's part of the problem.

    I've been working with a very detailed model and using the function drag / move in the color chart with no problems.  Then all of a sudden it stopped working.  Any thoughts?  I can drag and drop other items in, but not this model more.  Any thoughts?

    Try and select the object complete, then object > model > done. This can generate a more descriptive error message. Will there be a clipping mask in your work?

  • How to drag and drop multiple movieclips at the same time

    Hello world

    I'm a new actonscript 3 and adobe flash CC user and I am building an application but I have been stuck for several days. I have looked everywhere and tried everything I could think of, but I can't yet find a solution to my problem that I thought were pretty basic.

    Basically, let's say I have a rectangle and a circle on the stage. Once I did of the movieclips and assigned an instance name to each of them, I want to be able to perform a drag and drop the Rectangle so that both the rectangle and the circle become movable at the same time.

    For now, I have a mouse down events listener associated with the instance of rectangle, a method startDrag assigned to the rectangle instance and another assigned to the circle. But in this configuration, when I click on and drag the rectangle, only the circle is mobile (only the last line in the code is taken into account).

    I don't know if what I'm trying to achieve is feasible, but any help will be greatly appreciated, thank you!

    The startDrag() method can only work for one object at a time, so in your case the Treaty the last of them, designated the task.  This approach is to temporarily to plant the two objects in a container and then drag the container.

    rectangle.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);  When I click on the rectangle

    var dragMC:MovieClip = new MovieClip();
    addChild (dragMC);

    function fl_ClickToDrag(event:MouseEvent):void

    {
    dragMC.addChild (rectangle);        move objects in the container
    dragMC.addChild (circle);
    dragMC.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop); When I release the mouse button

    function fl_ReleaseToDrop(event:MouseEvent):void

    {
    dragMC.stopDrag ();
    Rectangle.x += dragMC.x;         Adjust the positions of the objects to their new location
    Rectangle.y += dragMC.y;
    Circle.x += dragMC.x;
    Circle.y += dragMC.y
    addChild (rectangle);                 move back to the scene objects
    addChild (circle);
    dragMC.x = dragMC.y = 0;       reset the benchmark for the dragMC
    }

    All this stuff of repositioning in the Drop function is necessary because when you drag the container, the positions of the content are still on their original coordinates inside the container.  So when you drop them they will resume their x / y positions in their new parent, meaning they go back where they were.  Reposition them where they have been trained to take into account the change in the position of the dragMC.

  • Need to drag and drop video clips over the keyboard to rotate

    My project is to allow visitors to the website drag furniture on a floor plan. I need all items be independent of each other with drag and drop and then be able to rotate each item with an arrow on the keyboard.

    The code I have allows all drag-and - drop, but I can't get the code to rotate an element. If anyone can help, I certainly appreciate. My Action Script 3 following code:


    / * Drag and Drop
    Makes the instance for the specified symbol with drag and drop furniture.
    */

    movieClip_1.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

    function fl_ClickToDrag(event:MouseEvent):void
    {
    movieClip_1.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

    function fl_ReleaseToDrop(event:MouseEvent):void
    {
    movieClip_1.stopDrag ();
    }

    / * Drag and Drop
    Makes the instance for the specified symbol with drag and drop furniture.
    */

    movieClip_2.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);

    function fl_ClickToDrag_2(event:MouseEvent):void
    {
    movieClip_2.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);

    function fl_ReleaseToDrop_2(event:MouseEvent):void
    {
    movieClip_2.stopDrag ();
    }

    stage.addEventListener (KeyboardEvent.KEY_DOWN, nextQuestion);


    function nextQuestion(event:KeyboardEvent):void {}
    trace (Event.keycode);
    if(Event.keycode == Keyboard.Right)
    {
    movieClip_1.rotation += 5;
    }

    if(Event.keycode == Keyboard.Left)
    {
    movieClip_1.rotation-= 5;
    }

    }

    Thank you, Frankie

    Create a variable to determine the last selected movieclip and allowing to target in the keyboard code.  Here is a smaller version of your code that does this, where drag and drop functions are shared by objects that can be moved...

    var selectedMC:MovieClip;

    movieClip_1.addEventListener (MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_2.addEventListener (MouseEvent.MOUSE_DOWN, clickToDrag);
    movieClip_1.addEventListener (MouseEvent.MOUSE_UP, releaseToDrop);
    movieClip_2.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;
    }
    }

  • Drag and drop work stoppages until the computer restarts

    We are experiencing a problem on some machines (Windows 7 SP1 64 bit) where slide - déposer ceases to function in all applications.

    For example, in Windows Explorer, you can initiate the drag, but when you release the mouse button to make the 'drop' the drag image/icon remains right on the screen.  Once you press the ESC operation key drag is cancelled and slide it image/icon disappears.

    There seems to be a sequence of actions in various applications as the user doest that tests the problem.  Even after closing all applications and even restarting Windows Explorer, disconnect and reconnect the mouse, the problem persists.  A reboot seems to be necessary to solve the problem.  We cannot identify any resource that is used as memory, GDI and user handles objects, etc., to the top.   Windows Process Monitor and Process Explorer have not ben useful.

    Do we know if there are a few key resources being locked that prevents drag it / move to fill?

    Actually figured this out in part.  It seems to be related to an application that has been hanging mouse events and leaving the passage of events in a bad state of a certain type.

  • Cannot drag and drop widgets (content) on the home page

    I have Windows Vista Ultimate Edition with Service Pack 2 and IE 9 on a 32-bit platform. My home page content cannot be moved. Make my icons on the desktop and working my doc files. What is the problem? Can I added the content simply not move anywhere on the page where I want.

    Hello

    1. don't you make changes to the computer until the problem occurred?

    2. this happens with all the gadgets?

    I suggest you to try the steps below and check if it helps.

    Uninstall, and then restore the desktop gadgets. Follow the steps to uninstall the gadgets.

    a. right click on the empty area of the desktop and then click Gadgets.

    b. right-click on the gadget and then click Uninstall.

    Steps to restore the Google desktop gadgets:

    a. click Startand then click Control Panel.

    (b) in the search box, type Restore the Gadgets.

    c. click Restore gadgets installed with Windows Office

     

    Hope this information is useful.

  • Drag and drop with audio for the success or failure for each object

    Captivate 7

    I saw Pooja video on at least 20 times, literally, but I can't yet find the complete instructions anywhere. Not even in things, I spent a lot of money on. Ouch.

    ed.png

    I want to drag "ed" & "and" and get a snap sound as they settle. I got it work. But when he moves the words in the wrong location, I want a sound alert, allowing them to know that it is a mistake and do not want the box to accept the term.

    Sometimes video of Pooja, but it does not show how. I'm pulling out my hair. Soon it will get ugly around here.

    Sorry for that, I always use advanced actions and sometimes forget (late in the evening) that everyone knows with them.

    If you want to only play an audio clip when an object is moved and don't need a legend to appear or are happy with a legend of single failure (you can check that a new that), you can replace the command execute measures advanced in the screenshot of the other thread in "Play Audio"... »

    I've used here a clip audio, available with Captivate in the Gallery\Sounds

    Lilybiri

    PS: Since the CP6 I use the word "container" instead of legend because the text can be inserted, not only in the text captions, but also in the forms (my favorite)

  • Mail blocks on each drag and drop operation

    I click on an e-mail address to move it to a folder, and with the first mouse movement email crashes.

    -------------------------------------------------------------------------------- -------------------------------------------

    Process: Mail [7742]

    Path: /Applications/Mail.app/Contents/MacOS/Mail

    ID: com.apple.mail

    Version: 9.2 (3112)

    Generation information: Mail-3112000000000000 ~ 7

    Code type: X 86-64 (Native)

    Parent process:? [1]

    Manager: Mail [7742]

    User ID: 501

    Date/time: 16:04:32.814 2016-01-28 + 0100

    OS version: Mac OS X 10.11.3 (15 d 21)

    Report Version: 11

    Anonymous UUID: A62E7CD0-BA9B-3CDF-F8A8-080CB44CE05C

    Time since started awake: 24000 seconds

    Integrity of system protection: enabled

    Crashed thread: 0 dispatch queue: com.apple.main - wire

    Exception type: EXC_BAD_ACCESS (SIGSEGV)

    Exception codes: KERN_INVALID_ADDRESS at 0 x 0000000000000200

    Note the exception: EXC_CORPSE_NOTIFY

    VM regions near 0x200:

    -->

    __TEXT 0000000106f5c000-0000000107317000 [3820K] r-x/rwx SM = COW /Applications/Mail.app/Contents/MacOS/Mail

    Please launch the Console application.

    Step 1

    For this step, the title of the Console window should be all Messages. If it isn't, select

    SYSTEM LOG QUERIES ▹ all Messages

    in the list of logs on the left. If you don't see this list, select

    List of newspapers seen ▹ display

    in the menu at the top of the screen bar.

    In the upper right corner of the Console window, there is a search box to filter. Enter the name of the application crashed or process. For example, if Safari has crashed, you would enter "Safari" (without the quotes).

    Each message in the journal begins with the date and time when it was entered. Select the messages since the time of the last fall, as appropriate. Copy to the Clipboard by pressing Control-C key combination. Paste into a reply to this message by pressing command + V.

    The journal contains a large amount of information, almost everything that is not relevant to solve a particular problem. When you post a journal excerpt, be selective. A few dozen lines are almost always more than enough.

    Please don't dump blindly thousands of lines in the journal in this discussion.

    Please do not post screenshots of log messages - text poster.

    Some private information, such as your name, may appear in the log. Anonymize before posting.

    Step 2

    In the Console window, clear the search box, and then select

    DIAGNOSIS AND diagnostic USE information reports ▹ user

    (not diagnose them and use Messages) in the list of logs on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points downwards. You will see a list of reports of incidents. The name of each report begins with the name of the process and ends with ".crash". Select the most recent report on the process in question. The content of the report is displayed at right. Allows you to copy and paste to validate all of the content, text, not a screenshot.

    I know that the report is long, perhaps several hundred lines. Please report all this anyway. If the report is only a few lines, make sure that you have disabled the search box.

    If you don't see any report, but you know, he had an accident, you have chosen diagnostic and using the list of Log Messages. INFORMATION on the USE of DIAGNOSTIC AND choose instead.

    In the interest of privacy, I suggest that, before posting, you change the UUID ' anonymous, ' a long string of letters, numbers and dashes in the header of the report, if it is present (it cannot be). "

    Please do not post other types of diagnostic report - they are very long and rarely useful.

    When you post the journal excerpt or the accident report, you might see an error message on the web page: "you have included content in your post that is not allowed", or "the message contains invalid characters." It's a bug in the forum software. Thanks for posting the text on Pastebin, then post here a link to the page you created.

    If you have an account on Pastebin, please do not select private in exposure menu to paste on the page, because no one else that you will be able to see it.

  • Drag-and - drop text reader to the other application does not work

    Hello

    I have disabled protected mode in acrobat reader of the registry key... HKCU\Software\Adobe\Acrobat Reader\11.0\Privileged\bProtectedMode REG_DWORD 0

    This works when Acrobat Reader native app is used. When I open a PDF file in the browser (Acrobat Reader Plugin for IE11) then drag / drop do not work. Select, right click copy, destination Application as Word 2013 right click Paste, works.

    We use 11.0.12. Same problem was 11.0.11 too.

    Any ideas?

    Kind regards

    Roland

    Hi supports,

    Web browser uses only the PDF viewer plugin to view PDF files. It will have the same feature of the player.

    So if you want to use the drag & drop feature, please stick to the player application.

    Kind regards
    Nicos

  • Hi, I want to drag and drop a file in the form (in a grid view of data in the table of attachments in database-type access is incidental)

    I am using visual basic 2010. A shape has a datagridview named in an attachment that is connected to a binding source (access database) named attachments. The columns are attached and description. The attachment is not of type text, this is the type of attachment. How to download files in the access database by using my VB form.

    Can anyone suggest me how do. I'm new to VB. It'll be good if you can provide the code.

    Hello

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the MSDN Developer audience. Please ask your question in the following forum.

    VB general forum:
    http://social.msdn.Microsoft.com/forums/en-us/vbgeneral/threads

    Concerning

Maybe you are looking for