A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Rotate Object

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Posts
    4

    Rotate Object

    Hello there,

    I'm trying to rotate an object by using actionscript. I managed to rotate the object once. Further clicking on the object to make it rotate again does not work. here's my simple script look like:

    onClipEvent (mouseUp) {
    _root.right_mc._rotation = 45;
    }

    How do I make the object to rotate again subsequently everytime I click on the object?

    I appreciate your help.

    cmec

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    You want to tell flash to rotate your object an addtional 45 degrees on each click...

    _root.right_mc._rotation = _root.right_mc._rotation + 45;

  3. #3
    Junior Member
    Join Date
    Nov 2005
    Posts
    4
    Thanks for your reply. Ya, it works well. Thank you very much.

    cmec

  4. #4
    Junior Member
    Join Date
    Nov 2005
    Posts
    4

    Rotate and Drag An Object

    Hi, is it possible to drag an object and rotate it at the same time. I've tried the script below but there seem to be a confusion going on. I have replaced onClipEvent with "on (press)" since I want single object to rotate independently. Any idea how to make an object rotate and drag?

    --------------------------
    on (press) {
    _root.right_mc._rotation = _root.right_mc._rotation + 45;
    }

    on(rollOver)
    {
    Mouse.show();
    }

    on(press) {
    startDrag(this);
    }

    on(release) {
    stopDrag();
    Mouse.show();
    }

    on(rollOut)
    {
    Mouse.show();
    }
    on () {
    }

    --------------------------------------------

    Appreciate your help.

  5. #5
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I think the problem is, that when you rotate the object, there is a chance that the mouse will no longer be over the hit area of the object and there is confusion, as you say, and there is never any way to obtain your on(release).

    You could take the object you want to drag and rotate, and put it inside another movieclip. This "holder" movieclip would have an invisible object that covers both the object's original location and rotated location. You could put your action script to drag on the "holderMc" and have a script to rotate your movieClip inside.

  6. #6
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    does anyone know how to do this in AS3?

    i want to click on an object (like a dial), drag the mouse up and down to make it spin either direction.

    even better would be to drag up and down, and it would scroll through a series of images (that way i could take a picture of the dial in each position, it wouldn't be as smooth of an animation but it would work better for the application im building, becasue the shadows would show up in each position).

    the AS3 code for either of these methods would be really helpful thanks!

  7. #7
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    i knwo hwo to make all sorts of sliders and buttons, but rotating an object wiht mouse click and drag has proven more difficult.

    i'm wondering if you can use one of hte rotate functions (rotateAroundInternalPoint etc..)

    but i'm not sure how to set it up.

    also can i start out my code like this?

    (assuming the name of my spinning object is "dial")

    dial.addEventListner(MouseEvent.MOUSE_DOWN, spinObject);
    function spinObject(e:Event):void{
    dial.rotateAroundInternalPoint();

    or somethinglike that? anyone familiar with this part of AS3? i've been looking around on google for ages, found a lot of GREAT AS2 examples, but none wiht AS3......

  8. #8
    Freshman ActionScript Dev
    Join Date
    Jun 2009
    Posts
    8
    Have you tried this yet?
    Example:
    PHP Code:
    addEventListener(MouseEvent.CLICKrotateListenerfalse0true);

    function 
    rotateListener(e:MouseEvent):void {

    yourMovieClip.rotation += 45;


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