A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Dragging in a circle [locked center]

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    620

    Dragging in a circle [locked center]

    Hello...

    I have a MC that is a circle and I'd like to be able to drag it while locked to the center....

    I haven't found a piece of code that works... is this something simple, or am I just going crazy at this point?

    Thanks a MILLION in advance,
    -manny
    -could just be me though

    mannyme80

  2. #2
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    PHP Code:
    circle_mc.onPress = function () {
        
    startDrag(thistrue);
    }
    circle_mc.onRelease = function () {
        
    stopDrag();

    The startDrag(this, true);
    this = the circle
    true = lockCenter;

    IF the circle you have created is centered inside the symbol. (align to stage, center center)
    it will lock to the center of the circle as you drag
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    this works great, but I was a bit confusing...

    I have a circle MC, but i want to stay in place. I want to be able to drag it like a spinWheel... I'd like for the drag to only rotate the MC about its center.

    Hope this clears it up a bit.

    Thanks!
    -manny
    -could just be me though

    mannyme80

  4. #4
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    *bump*

    I really need help today... I have a close of business deadline to try and get this resolved...



    Thanks!
    -could just be me though

    mannyme80

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Posts
    620

    Flash file

    k....

    I have it rotating and dragging in a rotation... but i can't make it stop snapping to that certain point in the cirlcle MC

    Can anyone lend an eye!?

    Thanks!
    -manny

    Code:
    stop();
    
    _root.onEnterFrame = function () { 
    daWheel._rotation -=.2; 
    };
    
    daWheel.onPress = function(){
    	// when you press the grip in the daWheel
    	daWheel.onMouseMove = function(){
    		// add a mouse move event to the daWheel
    		
    		// get an angle to the mouse using atan2 (gets radians)
    		var angle = Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
    		// apply rotation to daWheel by converting angle into degrees
    		this._rotation = (angle*360/Math.PI/2);
    		// rotate the grip opposite the daWheel so it won't rotate along with it
    		this.grip._rotation = -this._rotation;
    	}
    }
    
    daWheel.onMouseUp = function(){
    	// if a mouse move event, delete it on mouse up
    	if (this.onMouseMove) delete this.onMouseMove;
    }
    Last edited by mannyme80; 05-30-2008 at 04:38 PM.
    -could just be me though

    mannyme80

  6. #6
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    what point does it keep snapping too.

    good job on finding the trig function. I was looking for it, but didn't look hard enough.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  7. #7
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    It keeps starting at the 0 or 360 degrees... regardless of how much as rotated...

    If my spinWheel has rotated 37 degrees, when I click to drag, it will snap back to 0 or 360 then drag.

    ugh!
    -could just be me though

    mannyme80

  8. #8
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    I took your exact code into my own fla, and when I click on the circle I made (it has a gradient so I can tell the rotation its at) it does not do anything. When I finally move my mouse, it points toward the mouse and does not go to 0 first.

    The problem is probably with the grip movie inside... can you post an fla with how those movie clips are setup. That could be the issue.
    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  9. #9
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    hope this helps!

    i'm really stressing :|

    -manny
    Attached Files Attached Files
    -could just be me though

    mannyme80

  10. #10
    Flactionscrish Baby Minion's Avatar
    Join Date
    Nov 2005
    Location
    Planet Earth
    Posts
    312
    Does this fix the problem?

    try this as your code

    PHP Code:
    stop();

    daWheel.onEnterFrame rotateDaWheel;

    function 
    rotateDaWheel () {
        
    daWheel._rotation -=.2
    }

    daWheel.onPress = function(){
        
    this.onEnterFrame null;
        
    // when you press the grip in the daWheel
        
    daWheel.onMouseMove = function(){
            
    // add a mouse move event to the daWheel
            
            // get an angle to the mouse using atan2 (gets radians)
            
    var angle Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
            
    // apply rotation to daWheel by converting angle into degrees
            
    this._rotation = (angle*360/Math.PI);
            
    // rotate the grip opposite the daWheel so it won't rotate along with it
            
    this.grip._rotation = -this._rotation;
        }
    }

    daWheel.onMouseUp = function(){
        
    this.onEnterFrame rotateDaWheel;
        
    // if a mouse move event, delete it on mouse up
        
    if (this.onMouseMovedelete this.onMouseMove;

    ktu[k-two]
    he who hesitates is lost; so i guess i'll wander intently

    Are you sure this is real?
    Life is Love, Love is Blind, Blind we go through Life.
    Life isn't hard, dealing with your self is.

    The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.


  11. #11
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    the same thing is happening... it will snap to the green slice...

    I'd like for the snap not to happen.

    I'll monkey around with it a bit longer... stressing out!
    -could just be me though

    mannyme80

  12. #12
    Senior Member
    Join Date
    Dec 2000
    Posts
    620
    PHP Code:
    on(press){
        
    dragging true;
        
    orig_mouse_angle Math.atan2(_parent._ymouse-_y_parent._xmouse-_x) * 180/Math.PI;
        
    orig_rotation _rotation;
        
    orig_x _parent._xmouse;
    }
    onClipEvent(mouseMove){
        if(
    dragging){
            
    curr_mouse_angle Math.atan2(_parent._ymouse-_y_parent._xmouse-_x) * 180/Math.PI;
            
    _rotation orig_rotation curr_mouse_angle orig_mouse_angle;
            
    updateAfterEvent();
        }
    }
    on(release,releaseOutside){
        
    dragging false;


    Thanks to Senocular.com this code does the CHARM!!!!

    WOOOHOOO!!!
    -could just be me though

    mannyme80

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