0

I am developing a flex screen, in which i have a canvas, above to that there will be a button, by clicking that button we can create panels dynamically.My problem is if a panel was manually dragged and kept in the position where new panel to be created then new panel have to be created somewhere else that means not above any other panels. How to achieve this..Pls give me any solution.Thanks

1 Answers1

0

my first idea is that you keep array of created panels. while creating new panel, you should check in this list if any panel colides with the one you created (get x and y position and width, height and check if it kolides or not)

tou can also create new component based on canvas and override its addChild method.

Misiakw
  • 902
  • 8
  • 28
  • Thanks for ur reply...i already have array of panels..but my doubt is how to check whether the panels collide ar not..thats where i got stuck... – Arvind_India Nov 28 '13 at 09:23
  • get coordinates of four points - each corners of new panel. then check if any of it is placed inside each other panel (test: otherPanel.x > newPanel.x > otherPanel.x+otherPanel.width and the same for y (and height). if there is no collision - place new panel. otherwise get new location and check again from the beggining. but in this case you can get stuck if there's no place sutable for new panel. I have some another idea that instead of checking collision you should initialy get(calculate) sutable position, but i have to rethink it again. – Misiakw Nov 28 '13 at 11:17