-
Iteration (I think)
Ok I have a movieclip that rotates on the press of a button. It works up to a point - it rotates nicely until it gets half way through when it spins endlessly, until that is I keep pressing the button (increasing the angle variable) until a certain value is reached.
The code is as follows:
In the timeline:
angle = 3420;
speed = 10;
_root.onEnterFrame = function() {
_root.circle._rotation += (angle-_root.circle._rotation)/speed;
};
The button:
on (release) {
angle = angle+45;
if (angle>=3779) {
angle = 3735;
}
}
I know the angles I've chosen are weird but it will circulate round 360 degrees for these angles - 3420 - 3780. Can anyone tell me why. And can anyone offer up a fix so it doesn't have to operate just within these angles.
Cheers,
O.
-
I don't quite see what you're trying to accomplish by making it so complicated.
There's probably a reason, however, so could you please explain?
This is one way to do it:
on (relase) {
_rotation+=15;
}
That would work.
Currently you have it moving every frame by your script in the root.
So try that and see if it is what you want. You're probably trying to do something special but I don't quite understand what.
-
Thanks,
I am new(ish) to actionscript and so probably am doing this in an overcomplicated way. However what I want to achieve is a circle that roates through the specified number of degrees rather than jumping directly to it.
The iteration formula formula I've used works in theory (and in Excel) by gradually increasing the rotation up to the specified amount (after about 200 calculations) but in Flash it get's into some weird loop and infinately rotates after 180 degrees.
????
-
Something you should know about the angles in Flash is that it works like this (assuming your movie clip is facing right):
-90
180 0
90
So all of those are negative numbers.
If you had a clock, 12 o'clock would be -90, 11 o'clock would be -120, etc.
It doesn't go all the way up to 360º.
-
Ah, that's interesteing. Thanks for the tip. I'll see if that's what's buggering up the maths.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|