PDA

View Full Version : Button stay selected!



gllanci
December 23rd, 2005, 08:26 AM
Hi

Im tryong to make 4 button but when the web is started the 1st button must be selected and the other thrre buttons must be enabled , if the user clicked the other button the button that was selected must come enabled!


can somebody help me please??


Best wishesh
gllanci

master_phat
December 23rd, 2005, 09:01 AM
this version is prolly really lengthy but...

btn1.enabled = false;

btn1.onRelease = function(){
btn1.enabled = false;
btn2.enabled = true;
btn3.enabled = true;
btn4.enabled = true;
}

btn2.onRelease = function(){
btn1.enabled = true;
btn2.enabled = false;
btn3.enabled = true;
btn4.enabled = true;
}


btn3.onRelease = function(){
btn1.enabled = true;
btn2.enabled = true;
btn3.enabled = false;
btn4.enabled = true;
}

btn4.onRelease = function(){
btn1.enabled = true;
btn2.enabled = true;
btn3.enabled = true;
btn4.enabled = false;
}


...again there is prolly an easier/efficient way but... I know I used that way for a while now jus' cuz it workz. Btw that goes on the first frame of your main movie, and btn1,btn2,btn3,btn4 are instace names given to the 4 movieclips btns.

gllanci
December 23rd, 2005, 09:09 AM
thanx a lot man!!

that is nice!!

regards,
gllanci

gllanci
December 23rd, 2005, 09:36 AM
Check the Attachment the fla

that is what I wannted but is that possible when the user gets inside the web the first button to be selected???


thanx

master_phat
December 23rd, 2005, 10:08 AM
the problem is your drop down menu is an mc with a btn embedded.. which doesnt work so well. It's saying when like
first_item.menu_btn.onPress = buttonHandling;

If I werez you I would just go dl another dropdown menu or something cuz this one is kinda bogus for the method you wanna do.

first_item.enabled = false;
first_item.onRelease = function() {
first_item.enabled = false;
second_item.enabled = true;
third_item.enabled = true;
fourd_item.enabled = true;
trace("pressed 1");
};
second_item.onRelease = function() {
first_item.enabled = true;
second_item.enabled = false;
third_item.enabled = true;
fourd_item.enabled = true;
trace("pressed 2");
};
third_item.onRelease = function() {
first_item.enabled = true;
second_item.enabled = true;
third_item.enabled = false;
fourd_item.enabled = true;
trace("pressed 3");
};
fourd_item.onRelease = function() {
first_item.enabled = true;
second_item.enabled = true;
third_item.enabled = true;
fourd_item.enabled = false;
trace("pressed 4");
};


put that code on a new layer above layer 2 and in the first frame(so you wont get confused) but it should work for disabling the 1st btn and whichever one you click after that. Thing is it doesn't work with the drop down menu cuz honestly.. it's butthole. :) Try to find a drop down menu that is just like a movieclip, or you can edit the one you have now to say like...

first_item.onRollover = function(){
this.gotoAndStop("rollover");
}

therefore not only can you have a sexy rollovers but you will be learning an efficient way of flash by keeping your entire movie actions on one frame :P

Just play around I'm sure you'll get it :cons:

gllanci
December 23rd, 2005, 11:20 AM
thanx a lot man !!
Im trying to make a animacion button when u click that button the button will play and getURL then if you click another button the button that is pressed must play to the end and then play the next pressed button!!


thnx a lot!!

regards

Barn
December 23rd, 2005, 11:55 AM
Really all you need to do is have each button event terminate the clicked state of the button reference stored in some sort of "last button clicked" variable, and then set itself as the last button clicked. There's no need to set the states of all existing buttons on every button click since only one could possible be the one last clicked.

See the example files on Button States at http://www.canfieldstudios.com/flashmx

master_phat
December 23rd, 2005, 12:21 PM
"last button clicked" variable

all the guy did was make what I had into a for loop.. using
this.enabled = false;
and
this.enabled = true;

for the different btn onRelease actions. In the long run itll basically be the same thing as I wrote, except less copy and pasting. Thing is though as I tried to explain, if you take a look inside the Movieclip btns, they are just frames with labels for the different states;instead of making a tradition btn. That is why his wouldnt work in the first place :kir:

Barn
December 23rd, 2005, 12:33 PM
Using frame labels of _up, _over, and _down, the actions of a standard button can be achieved with a movieclip (put a stop() action on the first frame) without using gotoAndStop() -- it will automagically go to those frames if even one button event handler function is created.


fncPress = function(){
_root.lastClick.enabled = false;
trace("pressed button: "+this._name);
_root.lastClick = this;
}
first_item.onPress = fncPress;
second_item.onPress = fncPress;
third_item.onPress = fncPress;


Or, if they're properly name, i.e. mvcBtn0, mvcBtn1, mvcBtn2, etc.


qtyBtns = 10;
fncPress = function(){
_root.lastClick.enabled = false;
trace("pressed button: "+this._name+" whose number is "+this.nbrID);
_root.lastClick = this;
}
fncBtnInit = function(){
for (var icrBtn=0; icrBtn<qtyBtns; icrBtn++){
rfcBtn = this["mvcBtn"+icrBtn];
rfcBtn.nbrID = icrBtn;
rfcBtn.onPress = fncPress;
}
}
fncBtnInit();