dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Hide the Clicked Button

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24

    Hide the Clicked Button

    in Director, you can use 'Me' to call on the object that has been clicked, dragged, whatever...

    is there a way to call on an object in flash in that same way?

    for example, i'm wanting to have a button disappear once it is clicked. thing is, i have 25 buttons on the screen with different instance names.

    i could go to every button and put in 'button01._visible = 0;' but there's gotta be another way.

    something like...
    Code:
    on (release) {
         me._visible = 0;
    }

  2. #2
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    Code:
    on (release){
          setProperty("/myMC", _alpha, "0");
    }
    Last edited by geoffp08; 05-05-2003 at 03:30 PM.
    Moving at the speed of Flash

  3. #3
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    Code:
    on (release) {
            myMC._visible = false;
            //myMC._visible = true;
    }
    Moving at the speed of Flash

  4. #4
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24
    that's not really the 'dynamic solution' i'm looking for. i've got 25 buttons...each with different names.

    btn01, btn02, etc...

    i want to find one command to hide that button clicked.

    like a me._visible = 0;

  5. #5
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    Code:
    myButton = new Array();
    myButton[0] = "thisButton";
    myButton[1] = "thatButton";
    myButton[2] = "thoseButton";
    myButton[3] = "theseButton";
    myButton[4] = "yourButton";
    myButton[5] = "ourButton";
    //etc
    for (i=0; i<=25; n++){
    	_root[myButton[i]].onPress = function() {
    		myButton[i]._visible = false;
           }
    }
    Last edited by geoffp08; 05-06-2003 at 09:30 AM.
    Moving at the speed of Flash

  6. #6
    Senior Member
    Join Date
    May 2003
    Posts
    157
    whats wrong with :

    on(release){
    this.visible = false;
    }

  7. #7
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    I dont know, youd have to ask him?
    <whispers> I think its because he has 25 buttons in need of a dynamic solution ... shhh...
    Moving at the speed of Flash

  8. #8
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24
    Originally posted by ArmedJimmy
    whats wrong with :

    on(release){
    this.visible = false;
    }
    becuase this._visible = false; will make the whole movie invisible.

  9. #9
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24
    Originally posted by geoffp08
    I dont know, youd have to ask him?
    <whispers> I think its because he has 25 buttons in need of a dynamic solution ... shhh...
    if i wanted to make 25 buttons (along with the movie) disappear i could.

    i just want the button that has been clicked to disappear.

  10. #10
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    thats why he had it enclosed in a button function: on (release)... right?
    Moving at the speed of Flash

  11. #11
    Senior Member
    Join Date
    May 2003
    Posts
    157
    if you put the code in each button it won't

  12. #12
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    if you use the array i provided earlier to define all your buttons (by instance name) you can call just a few lines of actionscript in the beginning of your movie to define that function for all buttons...
    Moving at the speed of Flash

  13. #13
    Senior Member
    Join Date
    May 2003
    Posts
    157
    Will your array method not hide everybutton when 1 is clicked?

  14. #14
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24
    to make sure i wasn't going crazy, i put the following script on a few of the buttons:

    Code:
    on (release) {
    	this._visible = 0;
    }
    the whole movie disappeared.

  15. #15
    Senior Member
    Join Date
    May 2003
    Posts
    157
    Dammit! Your right!

    You could put each button in a movie clip, that works for def.

  16. #16
    Junior Member
    Join Date
    Apr 2003
    Location
    Knoxville, TN
    Posts
    24
    Originally posted by geoffp08
    if you use the array i provided earlier to define all your buttons (by instance name) you can call just a few lines of actionscript in the beginning of your movie to define that function for all buttons...
    i did try that...

    Code:
    var myButtons = new Array();
    
    myButtons[0] = "button1";
    myButtons[1] = "button2";
    myButtons[2] = "button3";
    ...etc...
    then on the button i had a function being called which is needed for other things as well...

    Code:
    on (release) {
         theFunction(0, 1, 3);
    }
    and the actual function was setup to hide the button...

    Code:
    function theFunction(a, b, c) {
         //other crap
         _root.myButtons[c]._visible = 0;
         //other crap
    }
    doesn't give me an error or anything, just keeps on tickin, but without hiding the button.

    edit: i'm sure it's something little somewhere i'm missing. i hate that. ha.

  17. #17
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    Most (not all) of the above code refers to MC properties. You will need to make your buttons into MCs for this to work. IMHO, this is a better way to go in general anyway, as you can do anything with MCs that you can do with buttons, but you cannot to with buttons anything you can do with MCs.

    So, if you convert one of your buttons into an MC, and then use _this(bla bla) then you should have no problems. If it works, do this for all of your buttons.

    RH

  18. #18
    Senior Member
    Join Date
    May 2003
    Posts
    157
    here is how I'd do it(it works btw):
    Attached Files Attached Files

  19. #19
    Sonic the FlashHog geoffp08's Avatar
    Join Date
    May 2002
    Location
    Orlando
    Posts
    237
    Huh, I just tried duplicating my advice to help you and noticed the same issue... (guess thats why I dont use buttons in the first place) BUT how come it didnt work when I applied the same array and for loop to movie clips...?
    I suppose all along we could have put that code on 'each' button, but theres GOT to be an easier way to group that script than having to do it that way. It was a solution to the problem though, well done!
    Sorry about not being the help you hoped you would get...
    hope your problem is solved now
    Geoff
    Moving at the speed of Flash

  20. #20
    pablo cruisin' hanratty21's Avatar
    Join Date
    Mar 2002
    Location
    on the lam
    Posts
    2,275
    Originally posted by geoffp08
    Huh, I just tried duplicating my advice to help you and noticed the same issue... (guess thats why I dont use buttons in the first place) BUT how come it didnt work when I applied the same array and for loop to movie clips...
    See 3 posts above.

    RH

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