0
votes

I'm quite new to as3, and I'm heading with a (for me complex) problem. I have some identical objects (movieclips), wich I made draggable sqaures.

But I want to achieve the following thing: When I drag one of these objects to another one, I want them to "attach" to each other, just like in some "building games". And after two (or more) objects are attached, I need them to be draggable as a new whole. Which means if you click on any of them, every object drags along, en they stay om the same attached position.

I honestly don't know how to do this. I would appreciate if anyone could provide some examples or code.

Thanksin advance!

1
Have you tried some code? - Rajneesh Gaikwad
Sure, tried al lot of things.Also searched trhough multiple sites/forums etc. - Ajdin
You will have to show some piece of code so that you will definitely get the solution here. - Rajneesh Gaikwad

1 Answers

0
votes

Here's a simple algorithm for you:

1) Make an array that will hold "draggable" objects.
2) Upon selecting the first object add it to the array.
3) On FRAME_ENTER move (translate) all the object that are in the draggable array and check objects in the array collision with other objects. If the collision is true, add those objects to the draggable item array.

People here won't write code for you, it's up to you. But if you run into a problem where your code does not work how you intend it, feel free to post it and surely some help will come!