# Multiple Selection of Units

**URL:** <https://forum.kirupa.com/t/multiple-selection-of-units/117814>\
**Category:** Uncategorized\
**Created:** [July 30, 2004, 3:31pm UTC](https://forum.kirupa.com/t/multiple-selection-of-units/117814 "2004-07-30T15:31:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TjomasC](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@TjomasC](https://forum.kirupa.com/u/TjomasC)\
**Post date:** [July 30, 2004, 3:31pm UTC](https://forum.kirupa.com/t/multiple-selection-of-units/117814/1 "2004-07-30T15:31:19Z")

</div>

Ok, I’ll try to explain this simply (mainly for my benefit later :} )

I am making a game where you control ships by clicking on them, and then clicking else where on the screen to move them to that position, like on Command and Conquer and Age of Empires.

How could I create a something (box) that would allow me to click and drag, so selecting multiple units on my screen, and then allowing me to move them??

I’ve only got Flash MX, so none of that there new fangled Flash MX 2004!

Thanks in advance

---

<div class="post-metadata">

**Author:** ![dinner\_dog](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@dinner\_dog](https://forum.kirupa.com/u/dinner_dog)\
**Post date:** [July 31, 2004, 1:59pm UTC](https://forum.kirupa.com/t/multiple-selection-of-units/117814/2 "2004-07-31T13:59:20Z")

</div>

I’m trying to find the example I made a while back to see If I could. I got it all working but the problem was with the movement and getting the ‘units’ to check for each other so they don’t all end at the same point (and on top of each other). If I find the fla i’ll post it, or make a new one If I find the time. sorry, but perhaps this bump will find someone else who can help more than me at this pont.

---

<div class="post-metadata">

**Author:** ![dangerskew](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dangerskew](https://forum.kirupa.com/u/dangerskew)\
**Post date:** [July 31, 2004, 2:20pm UTC](https://forum.kirupa.com/t/multiple-selection-of-units/117814/3 "2004-07-31T14:20:04Z")

</div>

You could have a box that registers in it’s top-left corner, and then put this in it:

```auto

onClipEvent(load){
	hitX = 0;
	hitY = 0;
	hit = false;
}
onClipEvent(mouseDown){
	dragging = true;
	if(hit == false){
		hit = true;
		hitX = _root._xmouse;
		hitY = _root._ymouse;
	}
}
}
onClipEvent(mouseUp){
	dragging = false;
	hit = false;
}
onClipEvent(mouseMove){
	if(dragging){
		_x = hitX;
		_y = hitY;
		a = _root._xmouse - _x;
		b = _root._ymouse - _y;
		_width = a;
		_height = b;
	}
}
onClipEvent(enterFrame){
	if(hit){
		_visible = true;
	}else{
		_visible = false;
	}
}

```

I just made that up right now so it might not work

EDIT: Nevermind, that one isn’t very good; use this one I just made:

```auto

onClipEvent(load){
 hitX = 0;
 hitY = 0;
 hit = false;
 _root.createEmptyMovieClip("Line", 100000);
}
onClipEvent(mouseDown){
 dragging = true;
 if(hit == false){
  hit = true;
  hitX = _root._xmouse;
  hitY = _root._ymouse;
 }
}
onClipEvent(mouseUp){
 dragging = false;
 hit = false;
 _root.Line.clear();
}
onClipEvent(mouseMove){
 if(dragging){
  x = hitX;
  y = hitY;
  a = _root._xmouse - x;
  b = _root._ymouse - y;
  _root.Line.clear();
  _root.Line.beginFill(0xFFCC00, 50);
  _root.Line.moveTo(x, y);
  _root.Line.lineStyle(1, 0x000000, 100);
  _root.Line.lineTo(x + a, y);
  _root.Line.lineTo(x + a, y + b);
  _root.Line.lineTo(x, y + b);
  _root.Line.lineTo(x, y);
  _root.Line.endFill();
 }
}

```

---

<div class="post-metadata">

**Author:** ![TjomasC](https://avatars.discourse-cdn.com/v4/letter/t/9f8e36/32.png) [@TjomasC](https://forum.kirupa.com/u/TjomasC)\
**Post date:** [August 4, 2004, 11:57am UTC](https://forum.kirupa.com/t/multiple-selection-of-units/117814/4 "2004-08-04T11:57:10Z")

</div>

Thankyou!

This has saved me about 4 weeks more work!
