A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: problem with goto

  1. #1
    Actionscripter
    Join Date
    Jan 2004
    Location
    Montreal, Quebec
    Posts
    128

    problem with goto

    Hey. Im working on this simple game where u basically beat up some guy with weapons. Anyway, everything is goin smooth...I have a health bar on top, and I basically set it so that the health is 1000. In places, after:

    if(release) {

    I put in the code:

    if(hp == 0) {
    gotoAndStop("Dead", 1);
    }

    ("Dead" being the scene) For some reason, it doesnt seem to work and rather it goes into the negatives. If goin to a different scene doesn't work, then I wouldn't mind it being on the same scene, as long as he actually can die.

    Thanks for any help.

  2. #2
    Senior Member Genesis F5's Avatar
    Join Date
    Jan 2002
    Location
    Unallocated memory
    Posts
    1,845
    If this movie clip "dead" is on another scene, then you can't access it. It must be on the same scene. Actually, it must be visible. You can't change the properties of a movieclip on frame 100 if you're on frame 1 if each key frame is individually significant.

    You might want to post a very basic FLA omitting a lot of what's not needed to give us an idea of how it is setup.

    Try this though, and let us know if it works:

    _root.Dead.gotoAndStop(1);

    hope this helps.

    -genesis f5 (mx)

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Targeting scene names only works if everything is on the main timeline, not from movie clips, and not from external movies loaded on other levels. You should thus never target scene names, and allways target labeled frames instead.
    You should label the first frame of your "Dead" scene with an unique label such as dead (no number only labels or at least not starting off with a number, and no caps or special characters other than maybe the underscore if you must...), add _root (from movie clips) or _level0 (from external movies loaded on other levels) to your path and target that labeled frame...
    code:

    on(release){
    _root.gotoAndStop("dead");
    }
    //Or...
    if(hp == 0){
    _root.gotoAndStop("dead");
    }


  4. #4
    Actionscripter
    Join Date
    Jan 2004
    Location
    Montreal, Quebec
    Posts
    128
    Okay, I don't think that I explained it well. I dont want to goto a movie clip, just the first frame of the scene Dead. Alright, OldNewbie, I tried what you said, by labeling the frame, but it still doesn't seem to work.

    Now this is the most puzzling thing ever, and you probably can't help me, but I went and made an example, and it happened to work there!! So I rechecked my coding in my real game, and I don't see a difference.

  5. #5
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    You put the label between double quotes on the action itself, but not on the frame label itself? Same spelling? No caps?

  6. #6
    Actionscripter
    Join Date
    Jan 2004
    Location
    Montreal, Quebec
    Posts
    128
    Yep, made sure of that. Something is really messed up. Its not the end of the world if I dont get it, but I would like to. Well thanks for all of your help..sorry to have wasted your time .

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Are you trying this from some movie loaded on another level of your main movie? And if so did you try _level0 rather than _root?

    PS: You're not waisting my time... And it should work! Allways has for the last 4 years!

  8. #8
    Actionscripter
    Join Date
    Jan 2004
    Location
    Montreal, Quebec
    Posts
    128
    Hehe, yes I know that it has always worked

    No, its straight from first frame of my "script" layer in the actions panel

    Its allright, I'll just let it pass. Most people probably won't even attempt to reach 0 hp (takes a while), and if they do...well then they can tell me the game sucks

  9. #9
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Guess your game sucks then!

  10. #10
    Actionscripter
    Join Date
    Jan 2004
    Location
    Montreal, Quebec
    Posts
    128
    Perhaps

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