Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:33:28+00:00 2026-06-04T07:33:28+00:00

I have a generated application where one part is an exercise where the user

  • 0

I have a generated application where one part is an exercise where the user has to drag one or more items (text mainly, but images might be possible as well) and drop it into a box as seen below.

http://eastblue.org/dragdropexample.png

The box is a custom subclass of BorderContainer.
Each draggable item (a subclass of RichText) gets picked up in a MouseEvent.MOUSE_DOWN using startDrag(). When it gets released on MOUSE_UP it checks if it hit the box using this.hitTestObject(box) and if it didn’t hit, gets animated back to the start position. If it did hit, we do

stopDrag();
this.x = e.stageX; // e is the MouseEvent
this.y = e.stageY;

which works fairly well. The problem with this approach is that the draggable items can collide in each other, and that does not look very pretty.

I would like to prevent the draggable items from colliding in each other, and at the same time making sure they are kept inside the box.

I’ve considered solving this in two ways:

  • Creating some kind of grid inside the box, making sure each grid square is large enough to contain the biggest draggable item, and have the items appear in the closest free grid square.

    The problem with this is that the box and each draggable item can be any size and there can be any number of draggable items, so it’s a bit troublesome to make sure the user can drop every item inside the box if he wants to and still keep it looking okay.

  • Checking each dropped item against all the other items already inside the drop, and if they collide, move the newly dropped item a bit in one of the directions until they no longer collide.

    The problem here is keeping everything inside the box and not getting stuck in a loop trying to move in an impossible direction. And what if there is no way it can be moved?

Am I missing some obvious way, or a simpler way of doing this? And if not, how can I implement this as simple as possible?

Some collisions might be okay, since the user won’t be spending too much time with one of these exercises, but the way it works now they almost seem to seek each other out and crash horribly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:33:29+00:00Added an answer on June 4, 2026 at 7:33 am

    Use the DragManager as documented in the Flex help. Only put the accept code on your BorderContainer. Then make the items children of the BorderContainer, and give it a layout that does what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ExtJs application. When user needs to view PDF report generated on
One part of my application requires a bunch of images (representing scale) on screen.
I have an application which consists of 2 pages. One of those pages generates
i have developed an iphone application where i have generated a terms and condition
I have two XML files that are generated by another application I have no
I'm writing a Cocoa application where I have an auto generated app delegate:(MyAppDelegate.h/MyAppDelegate.m) So
I have an application that displays the data from 3 xml files (auto generated
I have a web application written in pure JavaScript (no pre-generated HTML except for
I have the following class as part of an asp.net application. public sealed class
Working on an ASP.NET MVC 3 (Razor) application, that's mainly concerned with UGC (user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.