A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: this should work....why doesnt it??!! simple actionscript problem

  1. #1
    Senior Member
    Join Date
    Mar 2004
    Location
    Darlington, England
    Posts
    209

    this should work....why doesnt it??!! simple actionscript problem

    hey guys any ideas???

    hey, im making a little flash game where the user has to click the right square to make the shape symmetrical. the actionscript in the first frame is as follows:

    stop();

    //ok, 'lives' is a dynamic text box which displays the amount of
    //tries the user has left
    //'last' is a movie clip that contains text saying "last chance"


    if (lives eq "1") {
    last._visible = true;
    }

    //'lost' is a movie clip that contains the text "wrong etc etc"
    if (lives eq "0") {
    lost._visible = true;
    gotoAndStop("15");
    }

    //the 'tick' and 'c1' to 'c10' are the crosses or ticks that show if
    //you click the right or wrong square.


    last._visible = false;
    tick._visible = false;
    c1._visible = false;
    c2._visible = false;
    c3._visible = false;
    c4._visible = false;
    c6._visible = false;
    c7._visible = false;
    c8._visible = false;
    c9._visible = false;
    c10._visible = false;
    c11._visible = false;



    ok, heres what isnt working, if the user has 1 try left the mc "last" doesnt become visible, and when the number of tries is 0 the movie doesnt jump to frame 15!!!

    in the second frame i have the following code which all works fine:

    stop();
    good._visible = false;
    ok._visible = false;
    finished._visible = false;
    lost._visible = false;
    finally._visible = false;
    if (lives eq "10") {
    good._visible = true;
    }
    if (lives eq "9") {
    ok._visible = true;
    }
    if (lives eq "8") {
    finished._visible = true;
    }
    if (lives eq "<=7") {
    finally._visible = true;
    }


    i dont have a clue why this isnt working, ive copied and pasted working code from frame 2 into frame one but it still doesnt work, any ideas????

    look at the fla, it will make more sense!!


    many thanks

    david
    Attached Files Attached Files

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    When targeting a frame number, you shouldn't use double quotes...
    code:

    if (lives == "0") {
    lost._visible = true;
    this.gotoAndStop(15);
    }


  3. #3
    Senior Member
    Join Date
    Mar 2004
    Location
    Darlington, England
    Posts
    209
    changed the double quotes, still no joy, any further ideas???


    Many thanks again

    Dave

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Well you'd still need to take out the double quotes, but also need to put your if statements in a loop, so they execute more than once, as they are not set to do...

  5. #5
    Senior Member
    Join Date
    Mar 2004
    Location
    Darlington, England
    Posts
    209
    ok, i understand what you mean but im afraid i dont know how to do it! do ui need to use the else statement???


    Many thanks and sorry for my stupidity!!

    Cheers

  6. #6
    Senior Member
    Join Date
    Mar 2004
    Location
    Darlington, England
    Posts
    209
    managed to come up with a work around, i put the if statement on the buttons instead so it checks the score each time a button is pressed and therefore doesnt need to be in a loop.

    however, i would like to know how to write loops so if anyone could either point me in the right direction or alter the above code into a loop so i know for next time i would be very grateful.

    thanks for any help

    david
    Last edited by daveyt11223344; 10-21-2004 at 11:13 AM.

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