A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Simple yet can remember

  1. #1
    Junior Member
    Join Date
    Nov 2001
    Posts
    29

    Simple yet can remember

    on a button im using this code:
    Actionscript Code:
    on (keyPress "1") {

        this.movie1.gotoAndPlay("2");      

    }

    I want the user to be able to press "1" again but this time it either resumes playing from the next frame OR gotoand Play another fram in the same movie.

    How would i do this. Many thanks you kind people
    Moo Power

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    On your frame actions, type this:

    Actionscript Code:
    secondHit = false;

    by this, we create a boolean variable (variable consisting of two values, TRUE and FALSE), and will turn it to TRUE once "1" has been pressed once, and then execute codes according to which value that variable has. So change your button code to this:

    Actionscript Code:
    on (keyPress "1") {
        if(secondHit == false){
            this.movie1.gotoAndPlay("2");
        } else { // in other words, if it's equals to FALSE
            // do something else
        }
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Nov 2001
    Posts
    29
    Hi , thanks for helping.... However im not getting this to work at present..

    on frame one (on frame actions) I have this
    Actionscript Code:
    secondHit = false;
    stop();

    THen on the button I have this:
    Actionscript Code:
    on (keyPress "1") {
        if(secondHit == false){
            this.movie1.gotoAndPlay("2");
        } else {
        this.movie1.gotoAndPlay("31");
        }
    }

    The first animation still works on the first press but on second press it replays the same animation (when it should be playing frame 31)
    Moo Power

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    oh, I AM SO DUMB Dx

    I forgot to turn the secondHit variable to TRUE :P:P:P:P:P

    Actionscript Code:
    on (keyPress "1") {
        if(secondHit == false){
            this.movie1.gotoAndPlay("2");
            secondHit = true;
        } else {
            this.movie1.gotoAndPlay("31");
        }
    }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Junior Member
    Join Date
    Nov 2001
    Posts
    29
    ah lol.
    When i fix my PC again I will try again, looks like it will work.
    Moo Power

  6. #6
    Junior Member
    Join Date
    Nov 2001
    Posts
    29
    Hello again. That works a treat. Can you see if you can help with a final adjustment...

    when I press "1" it does this:
    this.movie1.gotoAndPlay("2");

    When I press "1" again it does this:
    this.movie1.gotoAndPlay("31");

    When I press "1" again it does this:
    this.movie1.gotoAndPlay("31");

    Is it possible it can alternate so that if I press "1" it plays from frame 2
    press again it plays from frame 31
    press again it plays from frame 1
    press again it plays from frame 31

    etc etc

    THANK YOU THANK YOU THANK YOU
    Moo Power

  7. #7
    Junior Member
    Join Date
    Nov 2001
    Posts
    29
    actually...... Another issue has cropped up as i have more than one button. Can i send you a swf/upload a swf so I can explain better
    Moo Power

  8. #8
    Junior Member
    Join Date
    Nov 2001
    Posts
    29
    sorry to spam....But i decided to turn my brain on and type this:

    Actionscript Code:
    oneHit = false;
    twoHit = false;

    stop();

    then i have 2 buttons playing 2 movies

    Actionscript Code:
    on (keyPress "1") {
        if(oneHit == false){
            this.movie1.gotoAndPlay("2");              
             oneHit = true;    
         }else {
       
        this.movie1.gotoAndPlay("31");
        }
    }

    and button 2

    Actionscript Code:
    on (keyPress "2") {
        if(twoHit == false){
            this.movie2.gotoAndPlay("2");
             twoHit = true;
        } else {
       
        this.movie2.gotoAndPlay("31");
        }
    }

    So i think ALL fixed now!
    Moo Power

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