PDA

View Full Version : Need help with rotation.


mgttim
05-19-2004, 03:29 PM
I have a wheel that I made in Photoshop that I am trying to rotate like wheel of fortune, the problem I have is that if I import it into flash then create a tween it distorts the image, now if I use the same image and rotate it in code it does not distort the image. I want to use the tween option is there a way to do this and have the image look as good as it looks in PS?
Thanks in advance.


I am using flash 2004 and PS 7

Also see attached files 1 with code option and 1 with tween.

Ruben
05-20-2004, 07:29 PM
I don't really see the problem, why do you want to use tweening when you've achieved the same effect without distortion when you used AS??

:confused: - Ruben

pixelwit
05-20-2004, 09:31 PM
Not sure if this will make a difference or not but you could try opening the library, right-clicking the image and selecting "properties" then uncheck "Allow Smoothing".

-PiXELWiT
http://www.pixelwit.com

mgttim
05-21-2004, 11:32 AM
I have tried that also, the reason I want to use tween is so I can ease wich I have not succeffuly been able to accomplish in AS.

Ruben
05-21-2004, 11:42 AM
Alrighty, then here's the script for easing if you'd have an object moving from A to B:

aX = 50;
aY = 25;
bX = 75;
bY = 150;
//
easing = "fasttoslow";
factor = 0.1;
//
if (easing == "slowtofast"){
distanceX = bX - clip._x;
distanceY = bY - clip._y;
}
if (easing == "fasttoslow"){
distanceX = clip._x - aX;
distanceY = clip._y - aX;
}
//
clip._x += distanceX * factor;
clip._y += distanceY * factor;

Didn't test it but it should do it, good luck!

:) - Ruben

EDIT: Sorry, the 'fasttoslow'-part of the script contained a bug...Fixed it...:p

mgttim
05-21-2004, 05:02 PM
Thank you Ruben but I do have code to ease an object from point a - b but how do I apply that to rotation?

Ruben
05-21-2004, 06:08 PM
Well, I assume that you want to have the wheel turning and turning and turning and then on some point slow down and stop at some random point, here's the script:

randomPoint = Math.round(Math.random()*360);
slowDownFrom = 180;
rotateMax = 5;
speed = 9;
easing = 0.2
if (rotated < rotateMax){
if (_rotation >= 360){
wheel._rotation -= 360 - speed;
rotated ++;
}else{
wheel._rotation += speed;
}
}else{
if (_rotation < randomPoint - slowDownFrom){
wheel._rotation += speed;
}else{
wheel._rotation += (randomPoint - wheel._rotation) * 0.2
if (Math.round(wheel._rotation) == randomPoint){
wheelStopped = true;
}
}
}

There you go, don't be shy to ask questions if things don't work out ;)

Go nuts :p - Ruben

NOTE: Didn't test it, but if I were you I'd fill in a number that makes 360 if you multiply it a certain amount of times. So 90 or 45 or 36 or 18 or 9, etc, etc.

mgttim
05-21-2004, 06:54 PM
what does rotated equal

Ruben
05-22-2004, 04:47 AM
Oh, sorry, forgot to explain the vars...Here we go:

randomPoint = A random number between 0 and 360 where the wheel will stop
slowDownFrom = Amount of degrees it will take to slow the wheel down
rotateMax = The amount of times the wheel will take a turn before slowing down
speed = :p The speed with which the wheel turns
easing = The factor with which the wheel eases when it slows down
rotated = Amount of times the wheel HAS taken a turn ("rotated ++" increases the variable 'rotated' with one)

:) - Ruben

Mazi79
07-08-2005, 05:49 PM
I can't get this to work, does anyone have an FLA I could look at?

pixelwit
07-08-2005, 08:51 PM
Although different from the code Ruben posted, this thread (http://www.actionscript.org/forums/showthread.php3?t=49653) has a FLA which eases the rotation of a movieclip.

-PiXELWiT
http://www.pixelwit.com