-
Rotation
Hello, I have a mc named "arrow", which is obviously an arrow and using the below command, I have successfully made it rotate.
Actionscript Code:
onClipEvent (enterFrame) { _root.arrow._rotation+=1; }
But I want it to, when it reaches 0 degrees, start going the other way and when it gets to 90, start going the first way. This is what I have tried:
Actionscript Code:
onClipEvent (enterFrame) { _root.arrow._rotation+=1; if (arrow._x=90){ _root.arrow._rotation-=1; } if (arrow._x=0){ _root.arrow._rotation+=1; } }
And it does not work. Any help would be helpful. Thank you.
-
Senior Member
There are two things going on here. The first of which is in your if statement. You need to use “==”. A single “=” tells a variable what to be, where as double “==” compares the variable with another. The second thing is the order of operation. The very first thing you are doing is telling your arrow to rotate. By doing this (even if you were using “==”) the actual rotation of the arrow will never equal 0 or 90. This also becomes a problem because enterFrame commands continuously run from top to bottom until you tell it to stop.
Having said all that I am not sure this is the best method to use. If it was me I would either tween the movie clip or simply animate the arrow frame by frame in the movie clip.
Last edited by hts5000; 12-13-2010 at 09:17 AM.
-
Dignitary
The logic seems a little off as well.
-
Actionscript Code:
rotate = true; arrow1.onEnterFrame = function() { if(this._rotation<90 && rotate) { this._rotation+=1; if(this._rotation>=90) { rotate = false; } } if(this._rotation>0 && rotate ==false) { this._rotation-=1; if(this._rotation <=0) { rotate = true; } } }
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
|