# User to rotate a 2d object

**URL:** <https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456>\
**Category:** flash\
**Created:** [December 12, 2002, 3:36am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456 "2002-12-12T03:36:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![webworks](https://avatars.discourse-cdn.com/v4/letter/w/74df32/32.png) [@webworks](https://forum.kirupa.com/u/webworks)\
**Post date:** [December 12, 2002, 3:36am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/1 "2002-12-12T03:36:08Z")

</div>

This newbie in flash interaction has almost figure it out! I’ve done the drag and drop part, (thanks to a kirupa tutorial :beam: ) The only script left is the furniture rotation like you see on this page: [http://www.webworkshost.com/~fenwick/](http://www.webworkshost.com/~fenwick/)

[edited URL to my link]

This one uses a rotation button…is this the best way to do it?

If any one could _please_ help me out with an action script to rotate an object, I’d be forever in your debt!

Here’s the fla file…  
[http://webworkshost.com/linden2.fla](http://webworkshost.com/linden2.fla)

The graphics are kind of lame, but I’ll be improving on those as soon as I have the scripting together :crazy:

Heather Mc

---

<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:** [December 12, 2002, 3:42am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/2 "2002-12-12T03:42:42Z")

</div>

If you are using MX then there is a componant that can do this. Just drag and drop and attach to your clip 🙂

[http://www.flashcomponents.net/component.cfm?nav=2&id=132](http://www.flashcomponents.net/component.cfm?nav=2&id=132)

---

<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:** [December 12, 2002, 3:59am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/3 "2002-12-12T03:59:56Z")

</div>

I’m using Flash 5. Anyway to do it in Flash 5? Or, should I upgrade do you think?

---

<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:** [December 12, 2002, 4:02am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/4 "2002-12-12T04:02:57Z")

</div>

If you can afford an upgrade… go for it, definitely.

---

<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:** [December 12, 2002, 4:11am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/5 "2002-12-12T04:11:27Z")

</div>

I’ll hold off a little longer to see if anyone can help me do this in 5. $200 bucks profit loss is too much on this project…especially when I’m so close ☹

_fingers crossed_

---

<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:** [December 12, 2002, 4:15am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/6 "2002-12-12T04:15:51Z")

</div>

I would see if I could set something up for you. But you wouldn’t be able to open my Flash MX file anyway so it does no good

☹ I am sorry ☹

I hope a Flash 5er who knows how to do it reads this.

---

<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:** [December 12, 2002, 5:59am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/7 "2002-12-12T05:59:35Z")

</div>

Looks really good so far man… I think the only real complaint you might ever get though… Is if someone accidently drags a piece of furniture outside of the designated area… You might wanna put a drag limit on all of the clips as the size of the movie…

The Rotation thing looks great though… Or if you wanna do it like… If you press the left arrow key it rotates counterclockwise and if you press right arrow key it rotates clockwise…

If you need more info on how to do those things… Respond asap.

Good Luck  
Marz \<:}

---

<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:** [December 12, 2002, 9:59am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/8 "2002-12-12T09:59:30Z")

</div>

Marz, thanks so much for your response! The first link is only an example of what I’m trying to accomplish…completed by others.

Would you please take a look at my ugly fla file? There is no rotation script on that one yet.

I would most appreciate your help!

---

<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:** [December 12, 2002, 12:30pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/9 "2002-12-12T12:30:20Z")

</div>

A quick and dirty fix but it works

Hold down Shift when dragging to rotate anti-clockwise, hold down ctrl when dragging to rotate clockwise

I took out the pic as it was too big to post

3 parts:

Part 1  
Rotation function declared on frame 1 - takes 2 paramaters: object to be rotated and rotation speed

Part 2  
Button on mc to start/stop drag and to set var pressed

Part 3  
Function call bracketed in if clause to only call rotation function when mc is being dragged

---

<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:** [December 12, 2002, 6:20pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/10 "2002-12-12T18:20:52Z")

</div>

Thanks so much for the advice and putting that together. Unfortunately I think I need more help than I thought :\*( I’ve done every suggestion, upgraded to MX, tried the component (but I couldn’t figure out how to use the component)

So now I’m using jsk’s example to create the rest of the movie clips. I’m trying to find quick answers to the following:

1. Quickest way to import the rest of the furniture, and apply all the same scripting to the clips jsk created (probably not possible)

2. If there is no quick way…I’m making each clip one by one racking my brain as to how you create the _green_ transparent button/overlay to conform to the shape of the bitmap.

Well, if anyone has a little time! I just can’t seem to find the right tutorials :sigh:

---

<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:** [December 12, 2002, 8:43pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/11 "2002-12-12T20:43:39Z")

</div>

Wow, I’m almost there. I found a different way to do it, but the 2 pieces of furniture start rotating the minute they grab it and move it, but I’d rather the click & drag be separate from the rotation. I know it’s got to be something simple :sure:

---

<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:** [December 12, 2002, 9:35pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/12 "2002-12-12T21:35:14Z")

</div>

It’s quick to make the buttons, how many items of furniture do you have?

To make an invisible button:

1. Copy the graphic and paste it into a layer above the original.
2. Select the copy - click f8 and choose the button option.
3. Double click the button to edit in place and drag the keyframe in the up frame to the hit frame - i.e. edit the button so that the only frame containing a graphic is the hit frame.

That’s it! For the button to work you only need to define the hit area.

---

<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:** [December 13, 2002, 2:46am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/13 "2002-12-13T02:46:58Z")

</div>

jsk, I can’t thank you enough. Those instructions really did help me through this. Floorplan is Done!

[http://www.webworkshost.com/~fenwick/](http://www.webworkshost.com/~fenwick/)

\<:}

---

<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:** [December 13, 2002, 11:35am UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/14 "2002-12-13T11:35:55Z")

</div>

No worries, glad it worked.

---

<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:** [December 13, 2002, 6:53pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/15 "2002-12-13T18:53:40Z")

</div>

Hey all 🙂

A few folks say that the furniture gets stuck or refuses to drop/ release sometimes. I went back to the link and tried…sometimes the furniture sticks to the cursor, and sometimes it doesn’t. Usually this happens during a combination of dragging and rotating at the same time.

Do you know of anything that can be done to the file to prevent this? _fingers crossed_

[http://webworkshost.com/~fenwick/](http://webworkshost.com/~fenwick/)

[http://webworkshost.com/linden3.fla](http://webworkshost.com/linden3.fla)

---

<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:** [December 13, 2002, 7:44pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/16 "2002-12-13T19:44:25Z")

</div>

Oops forgot to put in swapDepths -

add

```
this.swapDepths(1000);

```

to your button so it now reads

on (press) {  
pressed = true;  
this.swapDepths(1000);  
this.startDrag();  
}  
on (release) {  
pressed = false;  
stopDrag ();  
}

The error is caused when someone releases a piece of furniture behind another piece - using swapDepths adjusts the z or stacking order of the objects so by setting an arbitrarily high value e.g. 1000 - you’re forcing the object currently being dragged in front of everything else so that you can’t release it behind another piece of furniture.

This will only work if all the furniture is on the same layer in your MC - as swapDepths will only adjust the z level within a layer. You can also swapDepths with a name instance of a MC if you want to jump layers and not just z levels but that’s probably overkill in this case

---

<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:** [December 17, 2002, 2:46pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/17 "2002-12-17T14:46:11Z")

</div>

Hi again!

Do you know of anywhere else that the swap depths should be added? For example, should this be on the rotate action on the clip as well perhaps?

I ask, because it still randomly won’t let go of the furniture…even if it’s away from another piece. I’d be more than willing to send you a check if you help me fix it \<:}

_hopeful_

[http://webworkshost.com/~fenwick/](http://webworkshost.com/~fenwick/)

[http://webworkshost.com/linden3.fla](http://webworkshost.com/linden3.fla)

Heather Mc

---

<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:** [December 17, 2002, 3:53pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/18 "2002-12-17T15:53:09Z")

</div>

I noticed the clip sticks to the mouse when you rotate the clip and the mouse isn’t over the piece of furniture. So it is over empty space around the clip.

My guess with this is that you should add an invisible area (alpha movie clip to 0) in the movie clip of the furniture so that you have your furniture and a radius area so your mouse will always be over the furniture. Does that make sense?..lol, not sure, it works in my head, but I never tried it.

---

<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:** [December 17, 2002, 4:32pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/19 "2002-12-17T16:32:42Z")

</div>

Yes! that does appear to be the problem…when cursor strays to white space. Would you mind telling me how I can do what you mention? I’ll try anything :crazy: I have to admit I’m struggling.

---

<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:** [December 17, 2002, 5:10pm UTC](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456/20 "2002-12-17T17:10:09Z")

</div>

No worries - more sloppy code on my part - I only coded for release not releaseOutside or dragOut

replace

on (release) {  
}

with

on (release, releaseOutside, dragOut) {  
}

and all should be well

[Next page](https://forum.kirupa.com/t/user-to-rotate-a-2d-object/9456.md?page=2)
