A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: making a button gotoandplay

  1. #1
    Member
    Join Date
    May 2008
    Posts
    34

    making a button gotoandplay

    Okay, I know this is one of the most common question-types asked around here, though this is my first real flash project and I just don't understand this stuff yet. The file is attached, I have a stop(); on 1, 38 and 39. I want it to sit the way it is at start, when you hit stage I would like it to go to frame 2 and play through to frame 38. (thats the part im on right now). Once I learn more about this button stuff I would like it so that when you hit launch, if you are on any frame besides 38, it shoots you to 39, if you're on 38 it will display a reaction time (that will be another story). The reaction time will be how long it took you to hit launch after the animation hits frame 38. (some sort of timer start on 38 and stop at button hit). Anyhow, I'm looking for some assistant on either getting my stage button to go to frame 2 or some help on all of this. Thanks for your time and help in advance.

    BTW: My stops were working until I tried to add my button code, now it just starts playing through every frame and ignores the stops, without any click at all.


    File is about 600kb and too big for attachment, it can be dl'd here:
    http://www.megaupload.com/?d=KGUZK8HY
    Put the code at the top in and click download

  2. #2
    Member
    Join Date
    Jun 2007
    Posts
    47

    Talking

    This is a very simple fix. I have looked at your file and the problem with your stop(); is that you have your stop(); and button actions on two different layers and you need to change the stage instance name to stage1 or something because flash already has stage declared in its library. You have to put all your actions in one layer. I always create an actions layer at the top of my flash file.
    This is what I did:
    Actions Layer:
    Code:
    stop();
    stage1.addEventListener(MouseEvent.CLICK,clickFunction);
    function clickFunction(evt:MouseEvent):void {
    	gotoAndPlay(2);}
    Also remember to change the instance name to stage1 or stage_btn, just not stage.

    Then insert to key frames at 38 and 39 and add stop(); actions.

    As far as the launch button, all you have to due is add an if else statement inside the action of the launch button.

    If you need anymore help, please feel free to ask.

  3. #3
    Member
    Join Date
    May 2008
    Posts
    34
    Oh that's great news, I was almost there! I will get to work on this first thing in the morning when I get back to work. I'll also update this thread in case I need any more information/help or even if I get it to work completely. Thanks for taking the time to look.

  4. #4
    Member
    Join Date
    May 2008
    Posts
    34
    Okay, so far I got this: http://berryequipment.net/tree.swf
    With no errors and working correctly as of now. Now I've simply ran in to now knowing how to create the timer. I have seen Timer.something and somethign with start(); reset(); stop(); but don't know how to display the time and really how to control the starting/stopping/resetting of that timer. I tried it out and it just gave me errors, so I definitely had it wrong.

  5. #5
    Member
    Join Date
    May 2008
    Posts
    34
    Okay, I think I have a start in the right direction, though it's not doing the correct function yet (obviously by looking at it). I think I may be setting it correctly and starting it, just not timing right. I don't know if I'm even setting it right even more since I added my if statement, heres the code I have (placed on keyframe 38)

    Code:
    stop();
    var myTimer:Timer = new Timer(0);
    myTimer.addEventListener(TimerEvent.TIMER, doStuff);
    function doStuff(event:TimerEvent):void {
    
    gotoAndStop(1);
    }
    if (currentFrame == 38) {
    myTimer.start();
    myTimer.stop();
    }

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