Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 5 of 5

Thread: please help

  1. #1

    Default please help

    ok heres what i need help with


    with this the score counts down from 10 to 0
    1 for every coin the main MC hits

    if (_root.coin.hitTest(this.hero_hit)) {
    collected_coins++;
    _root.level1_text.text = 10-collected_coins+" more to go";
    }

    i tryed to duplicate this to make a "lives" system, but it didnt work
    it keeps showing up in the actual game as "NaN left"

    if (_root.wall.hitTest(_x, _y, true)){
    lives_left++;
    _root.lives.text = 5-lives_left+" left";
    }


    can anyone tell me what im doing wrong?

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    I suspect that your issue is that you havn't told Flash that "lives_left" is a variable before trying to increment it. Try setting the value of the variable to 0 before using the variable...
    Code:
    lives_left=0;
    if (_root.wall.hitTest(_x, _y, true)){
    lives_left++;
    _root.lives.text = 5-lives_left+" left";
    }
    hope it helps
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  4. #3

    Default

    ok, i replaced the code as you wrote, and it doesnt shoe up as "NaN left" anymore

    now it counts down to 4 but stops there and wont go any farther

  5. #4
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    The example was not meant as a cut and paste code sample. It was to show that a variable needs to be declared before being used....at least since Flash8. Where you declare your variables is also important. Try declaring the variable outside of the hitTest.....in fact, above all other code except for other variable declarations.

    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  6. #5

    Default

    ok, i put it out of the hitTest
    it worked
    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial