A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [RESOLVED] Buttons in MovieClip Don't Work

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24

    resolved [RESOLVED] Buttons in MovieClip Don't Work

    I'm trying to make a game and, when you encounter enemies or go into a building, your x and y coordinates are recorded as variables and then loaded when you exit. I was trying to make this happen using hitTest but couldn't get it to work, so I am now trying to make a menu appear with buttons, such as "Enter" or "Leave" and "Fight" or "Run".

    Problem with this is that i can't get the menu to appear only when the character hitTests an enemy or door, it is constantly there. I tried resolving this by making the menu a movieclip with 2 frames, one empty and one with the movie, this makes the menu appear on collision, but the button does not work properly. I also tried using the alpha values, but the button remains in the middle of the screen invisible.

    So basically I am asking for suggestions on how to solve this problem and if you need more specific information just ask

    (BTW using Flash 8 but would like to keep it compatible with Flash MX)

    (I have another problem to be solved as well but it's not that major, yet)

    Thanks.
    Last edited by Work!; 09-27-2008 at 07:45 PM.

  2. #2
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    Why don't you just have to frames for the menu?
    So basically this would go into the menu movie clip
    PHP Code:
    onClipEvent(enterFrame)
    {
         if (
    _root.door.hitTest(_root.character._x_root.character._ytrue) == true)
        {
              
    this.gotoAndStop(2); //The frame where the menu with the buttons is on
        
    }
        else
        {
              
    this.gotoAndStop(1); //Blank frame
        
    }

    That should do it...
    Needs an update...

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    Tried that, but then the button doesn't work.
    PHP Code:
    on (release) {
        
    characterx backg._x;
        
    charactery backg._y;
        
    _root.gotoAndStop("rfight");

    I have that on the "fight" button (rfight being the frame with the fight) and when the button is independently on the stage it works fine ( im testing it using dynamic text box) but once it is within a movieclip it comes up with either nothing or "undefined"

    (and if your wondering why is is backg's coordinates, it is because i'm making the background move, while the character just stays still in the centre)

  4. #4
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    Could you please upload the *.fla?
    I'll have a look then...
    Needs an update...

  5. #5
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    bit big, is there a site where i can host it?

  6. #6
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    ^I think I see what you did wrong...try this:
    PHP Code:
    on (release) {
        
    _root.characterx backg._x;
        
    _root.charactery backg._y;
        
    _root.gotoAndStop("rfight");

    Remember you have to change the code on other places aswell. When you are requesting characterx/charactery, put a "_root." in front of it.
    Needs an update...

  7. #7
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    maybe i could go back to the alpha idea and make a variable that activates when you encounter an enemy, so that i could say on the button, if variable is true do this and if not do nothing, but when i tried the alpha idea it wasn't working, i had

    if (enemy.hitTest(_root.character) {
    _root.menu._alpha = 100
    }

  8. #8
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    ok ill try it

  9. #9
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    mm now it goes to the fight scene, which it didn't before, but the variable remains undefined

    o w8, maybe if i added _root.backg._x

  10. #10
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    ^Which variables are local, and which are being used in other movieClips?
    Needs an update...

  11. #11
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    it works now, i guess no variables were local :b another question though, im using the frame idea, but how can i get the background to stop moving once the menu comes up, cause right now you can keep running around. I have an idea as to how which i'll try out now though...

  12. #12
    Junior Member
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    24
    ok all problems fixed, it Work!s

    thanks for the help pseudobot

  13. #13
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    No problem man!
    Needs an update...

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