# Rotating / Dragging objects

**URL:** <https://forum.kirupa.com/t/rotating-dragging-objects/552>\
**Category:** flash\
**Created:** [July 22, 2002, 1:48pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552 "2002-07-22T13:48:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![onebigeye](https://avatars.discourse-cdn.com/v4/letter/o/3e96dc/32.png) [@onebigeye](https://forum.kirupa.com/u/onebigeye)\
**Post date:** [July 22, 2002, 1:48pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/1 "2002-07-22T13:48:25Z")

</div>

Hi there,

I have a bunch of draggable objects and I want to be able to rotate them. Is it best ( possible ? ) to rotate them based on keypress or how might you go about this.

Here is my keypress code so far ( draggin works - rotate doesn’t )

on(press){  
this.startDrag(true);  
}  
on(release) {  
stopDrag();  
}  
onClipEvent (keyDown){  
if (!Key.isDown(Key.ENTER)){  
this.\_rotation += 45;  
}  
}

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2002, 3:36pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/2 "2002-07-22T15:36:44Z")

</div>

what are you trying to accomplish? Your code works fine, but what exactly would you like to accomplish?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2002, 4:48am UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/3 "2002-07-23T04:48:58Z")

</div>

What version of Flash are you using ? Because this wirks well with Flash MX (on and onClipEvent on the same object), but not with Flash 5 (you’d have to put a button inside your clip).

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2002, 4:06pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/4 "2002-07-23T16:06:47Z")

</div>

Hi there and thanks for the replies, I appreciate them!

What I am creating is an app that allows people to design their own apartment layout. Basically, I’ve got it working where someone can drag different pieces of furniture / appliances onto the floorplan and rotate / size the pieces as necessary. To accomplish the rotating / sizing feature, I’ve created a separate menu with buttons for each piece of furniture. ( see attached jpg )

Is it possible to create only one set of modifying buttons, which will automatically rotate / resize the item that is currently selected? I’m guessing this will require something like creating a variable that is updated and sent to the modifying buttons when an item is selected

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2002, 6:35pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/5 "2002-07-23T18:35:11Z")

</div>

Hello,

Just wanted to thank you for the replies. I’ve been able to create a function that does what I want.

Thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 23, 2002, 6:39pm UTC](https://forum.kirupa.com/t/rotating-dragging-objects/552/6 "2002-07-23T18:39:42Z")

</div>

You’re right!

You basically need a switch…

turn couch into a graphic  
turn couch graphic into a button  
turn couch button into an mc

put code on your buttons like this…

on frame 1 of your timeline, you could put something like this

```auto

var activebutton;

```

on your “couch” button (all your buttons)…

```auto

on(release){
	_root.activebutton=this._name;

}

```

this way, you could check in your a/s to see what the value of activebutton is, and pass it to your code

then,

//change property somewhere else with a button

```auto

on(release){
	active=_root.activebutton;
	trace(active + _root.rotate + _root.height);
	
	eval(active)._rotation=rotate;
	eval(active)._height=height;

```

if you use duplicatemovieclips or attachmovieclips, make sure your original button, which is inside a movie clip has code attached to it. That way your code will always work regardless of instance name.

I hope this was helpful.
