A Question On Prototype..
Started by davidhatton, Jul 06 2012 07:46 AM
10 replies to this topic
#1
Posted 06 July 2012 - 07:46 AM
Hi,
I wonder if any guru out there can tell me how this prototype functions because it's causing me a problem and I need to understand.
viz:
Button.prototype.enabled = false; // This code disables EVERY button in the movie, TRUE = re-enabled all buttons
New_game_button.enabled = true; // This code re-enables specific buttons should you need to
This code works perfectly. All buttons are disabled except for the New_game_button which is what I want.
This line of code which immediately follows the new_game button
row_1.button_1.enabled = true;
doesn't.
You can see my problem. The pro disables this button as it should BUT won't re-enable it.
Any ideas?
Many Thanks
David
I wonder if any guru out there can tell me how this prototype functions because it's causing me a problem and I need to understand.
viz:
Button.prototype.enabled = false; // This code disables EVERY button in the movie, TRUE = re-enabled all buttons
New_game_button.enabled = true; // This code re-enables specific buttons should you need to
This code works perfectly. All buttons are disabled except for the New_game_button which is what I want.
This line of code which immediately follows the new_game button
row_1.button_1.enabled = true;
doesn't.
You can see my problem. The pro disables this button as it should BUT won't re-enable it.
Any ideas?
Many Thanks
David
#2
Posted 06 July 2012 - 07:50 AM
Without seeing the .swi file, I can only guess:
Is the button name in the correct format/text
Is the button in the MC where the command is?........If not, give it a path
Does the button actually exist as a button?
Just a few thoughts.
Is the button name in the correct format/text
Is the button in the MC where the command is?........If not, give it a path
Does the button actually exist as a button?
Just a few thoughts.
peterg,
SWiSH, SWiSH, SWiSH, SWiSH.....SWiSHing!! :)
SWiSH, SWiSH, SWiSH, SWiSH.....SWiSHing!! :)
#3
Posted 06 July 2012 - 08:21 AM
Thanks for replying Peter.
Yeah, this is what I don't understand about the code. If the prototype disables it (which it does) why can't it re-enable it. I've tried every option for the path. It exists as a button in that it is a movie clip with a 'on release' action in it. It is not defined as a button but acts like a button and it is disabled as a button.
Something I've just noticed is that if a button is a target, enable won't work. enabled = false works, enabled = true doesn't work.
David
Yeah, this is what I don't understand about the code. If the prototype disables it (which it does) why can't it re-enable it. I've tried every option for the path. It exists as a button in that it is a movie clip with a 'on release' action in it. It is not defined as a button but acts like a button and it is disabled as a button.
Something I've just noticed is that if a button is a target, enable won't work. enabled = false works, enabled = true doesn't work.
David
#4
Posted 06 July 2012 - 07:05 PM
David:
You need to upload you working file or an exact replica example.
Wayne
You need to upload you working file or an exact replica example.
Wayne
Wayne helps those who help them selves.
#5
Posted 06 July 2012 - 10:01 PM
Hi Wayne,
Thanks again for looking.
I've attached a swi that demonstrates the problem I'm having. I converted one of the 'buttons' to a button. The rest are still sprites which contain a mouse command. The prototype is in the scene_1 on load command..
David
Thanks again for looking.
I've attached a swi that demonstrates the problem I'm having. I converted one of the 'buttons' to a button. The rest are still sprites which contain a mouse command. The prototype is in the scene_1 on load command..
David
Attached Files
#6
Posted 06 July 2012 - 10:32 PM
Not sure but see if this is what you want.
Wayne
Wayne
Attached Files
Wayne helps those who help them selves.
#7
Posted 07 July 2012 - 03:19 AM
Hi Wayne,
Close but no cigar
I wanted the button which is clicked to change colour. You have showed me how to make it work though. I have placed button 1 over the top of button 2 and used alpha = 0 to make it transparent see attached). I'm sure that there is a more elegant way of doing it though. Did you notice that if you make the button a target the enabled code doesn't work? Is this documented anywhere? I can't find it.
Many Thanks
David
Close but no cigar
I wanted the button which is clicked to change colour. You have showed me how to make it work though. I have placed button 1 over the top of button 2 and used alpha = 0 to make it transparent see attached). I'm sure that there is a more elegant way of doing it though. Did you notice that if you make the button a target the enabled code doesn't work? Is this documented anywhere? I can't find it.
Many Thanks
David
Attached Files
#8
Posted 07 July 2012 - 06:10 PM
Let's work through your code.
First off you are setting all buttons to the off function
I changed the the structore of the movie, I added a circle over the movie clip and made it your button. Then all thats needed is to call the movie clip from this button.
Wayne
First off you are setting all buttons to the off function
onSelfEvent (load) {
Button.prototype.enabled = false; // This code disables EVERY button in the movie, TRUE = re-enabled all buttons
}
Now I've set onFrame 1 to activate a certain button.onFrame (1) {
button_1.enabled = true;
}
Now to use your other buttons you need to set them to "true" or active!I changed the the structore of the movie, I added a circle over the movie clip and made it your button. Then all thats needed is to call the movie clip from this button.
on (press) {
b_2.nextFrameAndPlay();
}
I named button_2 movie clip b_2.Wayne
Attached Files
Edited by cycle1500, 07 July 2012 - 06:44 PM.
Wayne helps those who help them selves.
#9
Posted 07 July 2012 - 07:22 PM
Hi Wayne,
That,s super. Many thanks for your help (again)
David
That,s super. Many thanks for your help (again)
David
#10
Posted 07 July 2012 - 08:37 PM
David:
We're not done yet.
Another way of doing this.
See file.
Wayne
We're not done yet.
Another way of doing this.
See file.
Wayne
Attached Files
Wayne helps those who help them selves.
#11
Posted 08 July 2012 - 08:19 AM
I got it Wayne! The button which is enabled/disabled cannot have code in it. It has to be a button which is without code which then points to the movieclip which contains the code.
Sheesh
But I've got it!!
Regards
David
Sheesh
But I've got it!!
Regards
David
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users













