A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Restart button issue

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    2

    Restart button issue

    I have created a timeline with a single play button. When pressed, the button will gotoAndPlay a specific frame (play frame x, stop at frame y). Once the timeline reaches the last frame I want the next press of the button to take you back to the start and have the ability to run through the timeline as before. The problem is, attaching a gotoAndPlay(1); on the last press will take you back to frame 1 but the play button no longer works.

    Everything I have is on the main timeline. I can't figure out why the button only works for one round.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    how do you have the button working, is it,
    on the button like so
    PHP Code:
    on (press) {
        
    play();

    or on the timeline like so
    PHP Code:
    button.onPress = function(){
        
    play();

    or attach your file
    Last edited by fruitbeard; 02-20-2013 at 11:22 AM.

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Anyway, perhaps you can try something like so
    PHP Code:
    button.onPress = function()
    {
        if (
    _currentframe == 1)
        {
            
    play();
        }
        else if (
    _currentframe == _totalframes)
        {
            
    gotoAndStop(1);
        }
    }; 
    effectively it disables the button until its either on frame 1 or the last frame

  4. #4
    Junior Member
    Join Date
    Feb 2013
    Posts
    2
    The code I'm using:

    forbtn.addEventListener(MouseEvent.MOUSE_UP, gostart);

    function gostart(Event:MouseEvent):void

    {
    gotoAndPlay(1);
    }

    This will rewind the scene back to frame 1 but the button will lose all functionality the second time through.

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Sorry, AS3, although my little test works fine with your code

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