Flash rotation Q
- Started
- Last post
- 33 Responses
- ********
When I need to clockwise-rotate a needle in a barometer and the starting degree is 320 (leftunder), and the end degree is 280(rightunder), what to do? Flash' rotation only goes clockwise from 0 to 180 degrees and counterclockwise from 0 to -180 degrees!
I tried to solve it with simple math but then the friggin' needle goes counterclockwise!! aargh!
anyway, it's inertia and here's the function:
-----------------------
rotate_it = function(obj, newangle, speed)
{ obj.onEnterFrame = function() {
this._rotation +=(newangle-this._rotation)/spee...
if(Math.ceil(this._rotation)==ne... {
delete this.onEnterFrame;
}
}
}-----------------------
thx in advance!
- jkosoy0
Maybe I'm making this sound easier than it is...but if your math has the needle going counterclockwise right now, what happens if you multiply * -1?
Wouldn't that flip it and make it go clockwise?
- ********0
i think not.. altho i should try..
the limit in flash is 180 anything beyond would be considered negative.. so 181 degrees would be considered -179 degrees in Flash, so if i'd get there it would become 179 when multiplied by -1, and not get me to the desired position.. quite confusing..
fact is, when i enter 181 the needle will just loop endlessly..
there must be a way!!!
(i will post the .fla in a minute then y'all can take a look!)
- ********0
here's the .fla and .swf in a zip-file (20 kb):
http://www.cymd.net/rotation_bar…
check the AS on frame 1 and on the go!-button..
thx!!!!
- ********0
Boz (Thx, Boz!) helped me out, but there was no inertia in his solution...
Someone thinks he or she can fix this WITH inertia movement?
tia!
- jpea0
i miss unfit
:-(
- ********0
me too.
*sigh*
- jkosoy0
sorry for the delay in response time. i've been doing anything but checking newstoday today. today. :)
anyway, lemme open this suckah up...
...sigh.
i need to reinstall flash one of these days. it refuses to open any file that i didn't create on this computer. :
have you tried flashcoders 4cy? i'm not gonna pretend like i know the answer here, especially since i can't open the fla.
- jpea0
*might as well chime in*
didn't open for me either.
is it 2004 or something?
- ********0
saved in regular MX:
http://www.cymd.net/rotation_bar…
gotta catch some sleep now.
any help is appreciated!
:-)
- jkosoy0
in this swf, variable angle is undefined. you're sending function rotate_it the following values:
needle,undefined,4.
http://www.kosoy.net/rotate/rota…
http://www.kosoy.net/rotate/rota…
I think this solves your problem? :)
- jkosoy0
oh no wait. i'm quite the idiot. i'll keep working on it. :)
- jkosoy0
yea, sorry about my above idiocy. its late and i've been staring at screens all day. :)
i'm gonna take a look at this tomorrow with fresh eyes. in the meantime, i'm gonna suggest flashcoders (i'll post a message there if you don't want to subscribe). that list is run by brandon hall; there must be some psychogenuis out there who has the answer to your problem.
g'nite. sorry i couldn't help more. i'm only 22 years old, i do what i can. :)
- ********0
hey, tis ok, thanks a lot so far!!
i might check that other forum somewhat later!
anyone else want to give this a shot?
- JamesEngage0
you probabl ywant to set up a virtual number that then maps onto the system that flash uses... i tried opening your file but it said it was 'unexpected'
- ********0
- JamesEngage0
so let me get it straight before I do anything... you want it to go clockwise no matter what.
- ********0
yep, as it should work like a barometer, minimum = left, maximum = right.
logically it should go all the way round from min to max, not take the shortcut.
i am almost believing this is impossible?
- JamesEngage0
what you need ot do is just keep adding so if you are on 180 and you want to go all the way around to 150 then you need to rotate 330 degrees... so you are aiming for 180 + 330 which is 510... one you are there, you can then take off the 360 again so you're back in a 0-360 range
- ********0
not quite sure if I understand, but if I do, then I've been there already..
In this file there's a line of code that substracts 180 if it's over 180 i believe..
the previous version without that line of code made it loop endlessly when over 180 degrees..
grrr.....!!!
- ********0
^ Bring Up My Post.