PDA

View Full Version : rotating mc with actionscript



denismatt
February 18th, 2003, 10:04 AM
Hi,
my problem is that even if the registration point of the MC I want to rotate is in its center it keeps rotating in its upper left corn.
The MC is a jpg I load dynamically.
The syntax I use is :

_root.photo._rotation += 90;

Any idea?
TY.

Guig0
February 18th, 2003, 10:06 AM
post your fla here so we can take a look at it...

senocular
February 18th, 2003, 10:07 AM
jpgs dont load in the center. They load from the upperleft corner down like in reading a page. What you can do is put the movieclip you load the image into inside another movieclip and position the jpg clip accordingly so you can rotate that new movieclip which holds it and have the image rotate from the center (which would be up and to the left from the center)

Guig0
February 18th, 2003, 10:56 AM
good to hear that...

denismatt
February 18th, 2003, 11:03 AM
I mean...

if I do the following:

_root.createEmptyMovieClip("container",1);
container.loadMovie("flower.jpg");
_root.container._rotation +=90;

I know that the mc rotates in the upper left corner but
if I draw a rectangle , I convert it into a mc and I set the registration point in its center and only than I load the jpg I believed that the rotation was in its center...
Why am I wrong?

pom
February 18th, 2003, 11:10 AM
Well you were wrong, that's all :) jpgs (and swfs) don't load in the center. But you can make a little script that will move your jpg when it's loaded :phil:

senocular
February 18th, 2003, 11:14 AM
it doesnt matter what you draw in the movieclip, like I said, loaded images always load from the upperleft corner down (and to the right). This is from the centerpoint of the movieclip they're loaded into.


+-------
| |
| image |
| |
-------


also, as I said before, what you'll have to do is have another movieclip to put it into so you can rotate that instead, positioning the loaded image within accordingly.

if the image is 240x480 then youd position container to be -120, -240 within the new rotating clip


_root.createEmptyMovieClip("rotater",1);
_root.rotater.createEmptyMovieClip("container",1);
_root.rotater.container._x = -120;
_root.rotater.container._y = -240;
_root.rotater.container.loadMovie("flower.jpg");
_root.rotater._rotation +=90;

pom
February 18th, 2003, 11:29 AM
Stop repeating what I say, Sen :bad: especially when I'm repeating what you've already said...

senocular
February 18th, 2003, 11:47 AM
stop writing such short replies so you dont post them faster than I can write mine ;)

Guig0
February 18th, 2003, 12:09 PM
do like me, always post something usefull ;)

senocular
February 18th, 2003, 02:05 PM
ok

Guig0
February 18th, 2003, 02:10 PM
see?

another useful post :P

senocular
February 18th, 2003, 02:14 PM
you always have to have the last post dont you

;)

Guig0
February 18th, 2003, 02:26 PM
:P

senocular
February 18th, 2003, 03:06 PM
told you :beam:

Guig0
February 18th, 2003, 03:09 PM
let me have the last word! :bad:

senocular
February 18th, 2003, 03:15 PM
ok

denismatt
February 20th, 2003, 03:53 AM
I appreciated your suggestions...it works fine now.
I need to work on it anyway.
Bye