A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Buttons clicked counter

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26

    Exclamation Buttons clicked counter

    Hiall,

    I need a bit of help with actionscript.

    Basically I have a kind of shoot the duck game I created, there are 8 ducks and each one have a button so when each duck is shot an ad comes up.

    Now the client wants something to happen when all the ducks have been shot, so I created this bit of AS which I put in the main timeline.

    var count;
    function doCount(){
    count++;
    if (count >= 8){
    gotoAndPlay ("goose");
    }
    }

    On each of the buttons, the AS is:

    on (press){
    _parent.ducks1_mc.duck_7_mc.gotoAndPlay(2);
    _parent.ducks2_mc.duck_7_mc.gotoAndPlay(2);
    _root.promos_mc.promo_07_mc.gotoAndPlay(2);
    _root.doCount();
    bt_7.enabled = false;
    }
    But everytime I shoot one it goes to "goose" when I want it to go there only when all the ducks have been "shot".

    hope someone could help me.

    Cheers
    MoDesign

  2. #2
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    use a trace command to see if your count variable is working.

    under 'count++;' put
    trace(count);

    should give you some answers
    Evolve Designs Interactive Media
    the natural selection

  3. #3
    Junior Member
    Join Date
    Jun 2009
    Posts
    1

    score for flash game

    hello
    i have designed a game with four buttons... which wen clicked score must increase in the dynamic score box.... i have used this script

    on (release) {
    score = Number((score))+50;
    }

    it is not working wen i click on the button at run time i get a msg " NAN " in the score box... wt should i do....

    i also want the button to disappear wen clicked on it n score should be displayed

    it will be great if someone would help me with this script

    thank

  4. #4
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26
    Hi Ryan,

    I've placed the trace in the place yu told me and the out put says NaN everytime i click or shoot a duck.

    Bit lost here, cheers!
    MoDesign

  5. #5
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    That's a good thing! It means using trace worked because it's telling us that 'count' is not returning a number (NaN = Not a Number). To fix this change:

    var count;

    to

    var count:Number = 1;

    I'm thinking after you change that the trace will return a number

    @kerinaonline - same problem, add var score:Number = 1; somewhere on your main timeline
    Evolve Designs Interactive Media
    the natural selection

  6. #6
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26
    Thanks Ryan,

    I'll try it out tonight and will keep you posted.

    Cheers,
    MoDesign

Tags for this Thread

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