A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: help with rotations for clocks and angles

Threaded View

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    78

    help with rotations for clocks and angles

    Happy New Year everyone,
    I'm trying bits of code to come to terms with AS3 within KM7. Eventually this will be used for students to move the arms of a clock to the correct time. Later in another project I want to move one arm to a specific angle for maths.
    The problem is the mc rotates from the middle not the end and it needs to also go backwards.
    Any help appreciated.


    minutehand.addEventListener(MouseEvent.CLICK, mouseClickHandler);
    minutehand.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

    hourhand.addEventListener(MouseEvent.CLICK, hourClickHandler);
    hourhand.addEventListener(MouseEvent.MOUSE_MOVE, hourMoveHandler);

    var mouseposx:int;
    var mouseposy:int;
    var dragablemin = false; // start with it still
    var dragablehour = false;

    function mouseClickHandler(evt:MouseEvent):void{ //test to see if it can be moved
    if(dragablemin == false){
    dragablemin = true;
    } else if(dragablemin == true){
    dragablemin = false;
    }

    trace(dragablemin);
    }


    function mouseMoveHandler(evt:MouseEvent):void{ // this shows rotation forward but from centre of mc not the end
    if(dragablemin == true){
    minutehand.rotation += 3; // mouse moves minute hand forward (+= 3) but "swaps' when passing over hour hand. How can this be stopped and
    } // (-= 3 moves it backwards so how can we have both - when student makes mistake)

    }






    function hourClickHandler(evt:MouseEvent):void{
    if(dragablehour == false){
    dragablehour = true;
    } else if(dragablehour == true){
    dragablehour = false;
    }

    trace(dragablehour);
    }


    function hourMoveHandler(evt:MouseEvent):void{ // rotates from the centre not the end
    if(dragablehour == true){
    hourhand.rotation += 3; // same as before you want the student to be able to go backwards if they made a mistake (-= 3)
    }

    }
    Attached Files Attached Files

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