A Flash Developer Resource Site

Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2001

    disabling a button during rotation of an mc

    Hi All,

    I am creating a spinning thumbnail machine that projects the thumbnail on a larger viewing screen. When you click the button for that wheel it turns with gears ect to the next thumb. I have that worked out, but want to disable the button during mc rotation so it can not be clicked multiple times the second or two the wheel is turning to the next thumb. Any ideas? Below is the script for one wheel and gears. That all works, just want to know how to disable the button during rotation.

    Thanks for any help.

    if(event.target == button1) {
    var turnTween:Tween = new Tween(Rotory_Mc, "rotation", Strong.easeOut, currentRot+Rotory_Mc.rotation, currentRot+Rotory_Mc.rotation+22.3, 1, true);
    var turnTweenCG:Tween = new Tween(CenterGear_Mc, "rotation", Strong.easeOut, currentCGRot+CenterGear_Mc.rotation, currentCGRot+CenterGear_Mc.rotation+22.3, 1, true);
    var turnTweenSG:Tween = new Tween(SecondGear_Mc, "rotation", Strong.easeOut, currentSGRot+SecondGear_Mc.rotation, currentSGRot+SecondGear_Mc.rotation-22.0, 1, true);
    var turnTweenSG2:Tween = new Tween(SecondGear2_Mc, "rotation", Strong.easeOut, currentSG2Rot+SecondGear2_Mc.rotation, currentSG2Rot+SecondGear2_Mc.rotation+22.0, 1, true);
    var turnTweenLG:Tween = new Tween(LargeGear_Mc, "rotation", Strong.easeOut, currentLGRot+LargeGear_Mc.rotation, currentLGRot+LargeGear_Mc.rotation+22.3, 1, true);
    var turnTweenLG2:Tween = new Tween(LargeGear2_Mc, "rotation", Strong.easeOut, currentLG2Rot+LargeGear2_Mc.rotation, currentLG2Rot+LargeGear2_Mc.rotation-22.3, 1, true);

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    press the picture...
    Give one name for the buttons somewhere in the beginning of the script:

    var buttonStopped:MovieClip;
    or whatever the superclass for the buttons is. Inside the the listener function you write:

    buttonStopped = event.currentTarget;
    buttonStopped.enabled = false;

    You need to create eventlisteners for the tweens, so you can enable the buttons again. Use fl.transitions.TweenEvent.MOTION_FINISH, for example:

    turnTween.addEventListener(TweenEvent.MOTION_FINIS H, finishHandler);
    function finishHandler(event:TweenEvent):void
    buttonStopped.enabled = true;

    Try this as a start.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Join Date
    Oct 2001

    Thanks cancerinform

    Thanks, looks good I will try this pronto! Will let you know.

  4. #4
    Junior Member
    Join Date
    Dec 2012
    when i do stuff like that, i add what i call "roots" to my movie...
    so for your situation.. i would put this piece of code on a separate layer called roots

    _root.rotating = 0;

    and when your movie starts, rotating will = 0.

    then where your actions for your button are.. tell it that if _root.rotating = 0 then the button is clickable... else.. its not...

    so then where your button tells the gears to rotate.. tell it to tell _root.rotate to = 1. and when it stops rotating.. tell it to go back to = 0 so you can click your button again...

    i use this same concept to implement a pause menu in games... pretty handy. and simple.

  5. #5
    Join Date
    Oct 2001


    I will try that it sounds like it will work good. Appreciate the help!

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