The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: Help needed with simple animation

  1. #1

    Help needed with simple animation

    Hi, can someone help me out with the button script for this simple animation?

    The functionality I'm after:

    - play button: click once to start animation. Once it's played through I'd like the car to stop on the last frame so we can see where it's ended up.
    - pause button: click to pause animation (play button will resume animation)
    - forward button: hold down to fastforward animation, release to pause on current frame, prevent from looping back to start after reaching final frame.
    - back button: hold down to rewind animation, release to pause on current frame

    As you can see I'm sort of half way there but struggling with the rest.
    Attached Files Attached Files

  2. #2
    Tompa's Avatar
    Trust me, I'm an engineer
    The orange parts is where I edited:
    pause_btn.addEventListener(MouseEvent.CLICK, onStopClick, false, 0, true);
    play_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true);
    function onStopClick(evt:MouseEvent):void {stop();}
    function onPlayClick(evt:MouseEvent):void {play();}
    forward_btn.addEventListener(MouseEvent.MOUSE_DOWN, autoInc);
    forward_btn.addEventListener(MouseEvent.ROLL_OUT, stopChange);
    rewind_btn.addEventListener(MouseEvent.MOUSE_DOWN, autoDec);
    rewind_btn.addEventListener(MouseEvent.ROLL_OUT, stopChange);
    stage.addEventListener(MouseEvent.MOUSE_UP, stopChange);
    function autoInc(mevt:MouseEvent):void {dir=2;
    function autoDec(mevt:MouseEvent):void {dir=1;
    function stopChange(mevt:MouseEvent):void {dir=0;
    var dir:int = 0;
    stage.addEventListener(Event.ENTER_FRAME, carMovement)
    function carMovement(e:Event):void{
            case 0:
                // 0 - Do nothing
            case 1:
                // 1 - Go backwards
            case 2:
                // 2 - Go forward
    Works flawless!

  3. #3
    Tompa thanks so much for your help I really appreciate it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012