PDA

View Full Version : Drag and rotate movieclip problem


Shorty
01-19-2002, 04:39 PM
Hi All,
I am starting a project which uses movieclips that can be dragged around and rotated/resized by the user.

I have created an MC that has an invisible button on it and have put the following action onto the button

on (press) {
startDrag (this);
}
on (release) {
stopDrag ();
}
on (keyPress "<Down>") {
_xscale -=10;
_yscale -=10;
}
on (keyPress "<Up>") {
with (this) {
_xscale +=10;
_yscale +=10;
}
}

The problem is when I make duplicates of this MC and put it on the screen only the first instance of the MC resizes.

Can anyone point me in the right direction ? is this something to do with depths?
I have given the movies different names and know that I could put an action on each individual movie and use an absolute path but in the future I wish to use a duplicateMovie command to alow the users to put as many MCs on the stage as they like and resize/rotate etc..

I have an example fla here http://www.btinternet.com/~hbomb123/scale.zip

Ultimatley I want to have similar to control to this cool xmas card site,
http://www.type289.com/clients/colorforms/test.swf

Anyone know of any tutorilas that break some of the stuff on this site down ?



Thanks In advance

Shorty

jimburton
01-19-2002, 11:08 PM
What I changed in your file was to use movieclips not btns, more flexible more sophis ways of watching for events. Attached copy of your file: it's beginning to work, but not perfect cos it changes only on keyUp, whereas you should make it work on a repeated keyDown, which is what people may expect. Let me know if it's any/no use...

Shorty
01-19-2002, 11:46 PM
Hi Jim,

Thanks for your help.

the use of MC instead of button is good tip thanks, though it does not solve my problem, I think I need to explain myself better having just reread my first post.

What I want to happen is for the movie clips to work independantly, so if the user clicks on the right hand clip and presses up or down only that clip will change leaving the other as it is, I could do this by writing script for each of the MCs seperatly but in the future I wish the user to duplicate the clips if they want to and still be able to resize/rotate each one in there own time.

In my searching I have come across the function script so I am wondering if I need to write a general function on the main timeline, and then get each clip to check on that function for its instructions ?

Hehe I am way outta my depth here as I am total noob to scripting, but I know it is possible as one of the links above shows , just gonna have to dig around till I work it out lol.

Ultimately I am trying to create a program that will allow me to move and rotate models of sailing dinghys on screen , I teach sailing and will use this to set up different scenarios for my pupils e.g where to be at the start of a race etc.. :)

Thanks Again

Shorty

poab
01-20-2002, 12:35 AM
Hi,

I don't know if this will work, but it should help. Alter your code like this (unfortunatly I think you need to use the button method, but not necessarily):

On timeline:

id = getProperty(this, _name);

On button:

replace every reference to 'this' with 'id'.

After you duplicate the Mc the code is refering to the names of each duplicated movieclip instead of using the generic 'this'.

I'm sure you could use it with the hitTest version if you want.

cheers.

pixelwit
01-20-2002, 04:43 AM
First off, I did some checking, apparently you can only have one keypress event in any one frame. That's why your mouse actions only work with whatever button is in the topmost layer (everyone else may have known this, but it was news to me).

Next, I'd stick with the keyDown event and set a variable noting which object is to be effected by the key event. This is probably better than what you were trying to do earlier because if you actually got what you were working on to work, all your clips (with buttons) on the stage would have been controled simultaneously.

As far as needing to use buttons goes, I think you can do just about anything a button can do by placing ActionScript on a MC.

Just my opinion. Hope it helps.

-PiXELWiT
http://www.pixelwit.com

Shorty
01-20-2002, 02:13 PM
Hi Guys:)

Thanks for replys,
Fisrt off poab I tried that method but it still made all of the rectangles resize or spin together? But thanks it was a useful thing to know about anyway.

Pixelwit can you give me some more information on what you mean ? I am still getting to grips with this scripting malarky.

BTW I do understand if you dont have the time, I know it must get be a pain having to spoon feed newbies :)

Cheers

Shorty

pixelwit
01-20-2002, 04:13 PM
Here comes the choo choo train, now open wide...

I attached a file for you to check out. Hopefuly it will clear some things up for you. :)

-PiXELWiT
http://www.pixelwit.com

Shorty
01-20-2002, 04:39 PM
MMM That was Yummy ;)

HEHE Thanks alot Pixelwit that is EXACTLY what I was looking for and I even think I understand it all too :)

Thanks Once again

Shorty

pixelwit
01-20-2002, 05:17 PM
If you'd like to repay your "debt", hang out in the Site Check forum and see if you can't help somebody else. Even "Newbies" can help other members in the Site Check forum. :)

If you'd like to do me a personal favor, you can check this thread and help find some search terms that describe my files. http://www.actionscript.org/forums/showthread.php3?threadid=8375

Glad to have helped,

-PiXELWiT
http://www.pixelwit.com