A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Rotation problem

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Location
    Anthem, AZ
    Posts
    18

    resolved [RESOLVED] Rotation problem

    hello all,
    I have an arrow that will point to your cursor, what I want it to do is rotate freely until I mouse over, and then rotate freely if i mouse off of it


    here is the free rotation code on the arrow

    Code:
    arrow.onEnterFrame = function ()
    {
        arrow._rotation = arrow._rotation + 5;	
    };
    and here is the code on the center of rotaion

    Code:
    onClipEvent (mouseMove) {
    	x=this._xmouse;
    	y=this._ymouse*-1;
    	angle = Math.atan(y/x)/(Math.PI/180);
    	if(x<0){angle+=180}
    	if(x>=0&&y<0){angle+=360}
    	_root.angletext=angle;
    	_root.arrow._rotation=angle*-1;
    	updateAfterEvent();}
    please i could really use some help here
    Almost never counts.

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    not exactly sure what you want to have happen, but immediately the mousemove jumps to mind. mousemove happens all the time, whether the mouse is over the element or not. so the mousemove is going to override the enterframe at all times. if you're trying to have the mousemove function only fire when the mouse is over the arrow, try setting the mousemove in a rollover, like so:
    PHP Code:
    arrow.onRollOver = function(){
    this.onMouseMove =function(){
    //... whatever you're doing
    };
    };
    arrow.onRollOut = function(){
    delete this.onMouseMove;
    }; 
    also - don't use clip events. assign handles like i did in the example above, like you did with the enterframe.

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Location
    Anthem, AZ
    Posts
    18
    thanks for the reply it was a huge help;
    but now i canot get it to start rotating again after i mouse out here is my code now

    Code:
    arrow.onEnterFrame = function ()
    {
        arrow._rotation = arrow._rotation + 5;	
    };
    arrow.onRollOver = function(){
    delete arrow.onEnterFrame;
    delete this.onRollOut;
    this.onMouseMove =function(){
    x=Rotate._xmouse;
    	y=Rotate._ymouse*-1;
    	angle = Math.atan(y/x)/(Math.PI/180);
    	if(x<0){angle+=180}
    	if(x>=0&&y<0){angle+=360}
    	_root.angletext=angle;
    	_root.arrow._rotation=angle*-1;
    	updateAfterEvent();
    };
    };
    arrow.onRollOut = function(){
    	delete this.onMouseMove;
    	arrow._rotation = arrow._rotation + 5;	
    };
    ok i think the delete code is wrong but im not sure
    Last edited by Tswanny; 08-01-2008 at 12:39 AM.
    Almost never counts.

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    at a guess, try this:
    PHP Code:
    arrow.onEnterFrame = function (){
        
    this._rotation += 5;    
    };
    arrow.onRollOver = function(){
    delete this.onEnterFrame;
    this.onMouseMove =function(){
    x=Rotate._xmouse;
        
    y=Rotate._ymouse*-1;
        
    angle Math.atan(y/x)/(Math.PI/180);
        if(
    x<0){angle+=180}
        if(
    x>=0&&y<0){angle+=360}
        
    _root.angletext=angle;
        
    this._rotation=angle*-1;
        
    updateAfterEvent();
    };
    };
    arrow.onRollOut = function(){
        
    delete this.onMouseMove;
    this.onEnterFrame = function (){
            
    this._rotation += 5;    
    }; 
    }; 

  5. #5
    Junior Member
    Join Date
    Jul 2008
    Location
    Anthem, AZ
    Posts
    18
    moagrius your a life saver, thanks!
    Almost never counts.

  6. #6
    ___________________
    Join Date
    May 2004
    Posts
    3,174

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