Rotating / Dragging objects

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!

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

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:

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.

Hello,

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

Thanks again.

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


var activebutton;


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


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


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.