A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Rotation

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    24

    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.

  2. #2
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    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.

  3. #3
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    The logic seems a little off as well.
    [SIGPIC][/SIGPIC]

  4. #4
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center