Skip to main content
March 8, 2012
Question

Animation couldnt control with Play pause toggle button..

  • March 8, 2012
  • 1 reply
  • 1196 views

I have multiple movie clip with bg sound.I have used the code AS3 for toggling the animation ( Play & Pause ).Automatically the animation starts and button also togggled on click but couldnt control the animation .

I need some solutions like when the intial stage the animation wont start etither the button click to play.After that the flow as it is in action ( ON Click ). Kindly anyone guide me to solve it. i'm very new to flash. this is my first project and ihave to finish it soon..

btns.visible = false;

btns.addEventListener(MouseEvent.CLICK,onEl);

dfr.addEventListener(MouseEvent.MOUSE_OVER,onEls);

dfr.addEventListener(MouseEvent.MOUSE_OUT,onEld);

btns.addEventListener(MouseEvent.MOUSE_OVER,onEls);

btns.addEventListener(MouseEvent.MOUSE_OUT,onEld);

var _vrSts:int = 0;

function onEl(eve:Event):void    {

    if(_vrSts)    {

        trace('status:'+_vrSts);

        _vrSts = 0;

       

        btns.gotoAndPlay(1);

       

      

    }else    {

        trace('status:'+_vrSts);

        _vrSts = 1;

        btns.gotoAndStop(2);

       

    }   

}

function onEls(eve:Event):void    {

    btns.visible = true;

}

function onEld(eve:Event):void    {

    btns.visible = false;

}

This topic has been closed for replies.

1 reply

March 8, 2012

Yes.. finally i got it.. here is it, but i need a help to visible the play button when pause the animation also starting stage with play buton. kindly help..

btns.visible = false;

btns.addEventListener(MouseEvent.CLICK,onEl);

dfr.addEventListener(MouseEvent.MOUSE_OVER,onEls);

dfr.addEventListener(MouseEvent.MOUSE_OUT,onEld);

btns.addEventListener(MouseEvent.MOUSE_OVER,onEls);

btns.addEventListener(MouseEvent.MOUSE_OUT,onEld);

var _vrSts:int = 0;

function onEl(eve:Event):void    {

    if(_vrSts)    {

        trace('status:'+_vrSts);play();

        _vrSts = 0;

       

        btns.gotoAndPlay(1);

       

        //btn.gotoAndStop(1);

    }else    {

        trace('status:'+_vrSts);

        stop();

        _vrSts = 1;

        btns.gotoAndStop(2);

      

    }   

}

function onEls(eve:Event):void    {

    btns.visible = true;

}

function onEld(eve:Event):void    {

    btns.visible = false;

}

Ned Murphy
Legend
March 8, 2012

You don't indicate anything in your code as being a play button so it is difficult to help you manage it.  Basically, anytime you stop the animation you want the play button to be visible, otherwise you want it to be invisible.  If the play button is part of btns, then you probably need to separate it so that you can control its visibility separately.  Otherwise, if it is already a separate object, then you can just do something like indicated below...

function onEl(eve:Event):void    {

    if(_vrSts)    {

        trace('status:'+_vrSts);play();

        _vrSts = 0;

       

        btns.gotoAndPlay(1);

       

        play_button.visible = false;

    }else    {

        trace('status:'+_vrSts);

        stop();

        _vrSts = 1;

        btns.gotoAndStop(2);

        play_button.visible = true;

             

    }   

}

March 9, 2012

Here i modified it, but action not applied ( Play & Pause control )

stop();

btns.visible = true;

btns.addEventListener(MouseEvent.CLICK,onEl);

dfr.addEventListener(MouseEvent.MOUSE_OVER,onEls);

dfr.addEventListener(MouseEvent.MOUSE_OUT,onEld);

btns.addEventListener(MouseEvent.MOUSE_OVER,onEls);

btns.addEventListener(MouseEvent.MOUSE_OUT,onEld);

var _vrSts:int = 0;

function onEl(eve:Event):void    {

    if(_vrSts)    {

        //trace('status:'+_vrSts);

        //play();

        _vrSts = 0;

        //btns.label = "Play";

        btns.gotoAndPlay(1);

        btns.visible = false;

       

        //btn.gotoAndStop(1);

    }else    {

        //trace('status:'+_vrSts);

        //stop();

        _vrSts = 1;

        btns.gotoAndStop(2);

        //btns.label = "Pause";

        if(currentFrame == 445)

            gotoAndStop(1);

           

        else

            play();

    }   

}

function onEls(eve:Event):void    {

    btns.visible = true;

}

function onEld(eve:Event):void    {

    if(_vrSts)

        btns.visible = false;

}