-
[RESOLVED] Need help at once
i try to make a virtual piano
i use popup to make a menu and hide the piano, but i still can press the piano button even the button is hidden
how can i make the button cannot be pressed while the menu is up ?
here is my virtual piano
Virtual Piano
-
Prid - Outing
Because it doesn't matter whether the movieclips are hidden or not, the associated codes, for instance the key press codes, will still work, except for the button properties, because they require the cursor to be interacted with.
On each button, before this line in onClipEvent(load) section:
type this:
Then, find this line:
Code:
if(_root.keys[Key.getCode()-65] == keyboard && keydown == false){
and change it to this:
Actionscript Code:
if(_root.keys[Key.getCode()-65] == keyboard && keydown == false && disabled == false){
Do this to all the buttons. Then add this code to your Frame Actions:
Actionscript Code:
function disableKeys(){ for(num=0;num<keys.length;num++){ _root[keys[num]].disabled = true; } }
function enableKeys(){ for(num=0;num<keys.length;num++){ _root[keys[num]].disabled = false; } }
This makes two functions, one to disable all the keys, and the other to enable all the keys. Since you've named the movieclips after their key on the keyboard, just like all the strings (letters) in the keys array, it's much easier to target all the desired movieclips, so when you make any further notes, make their instance name the same as their key to press.
To demonstrate the usage of the function, on your Frame Actions, after the above functions, simply type this to call the function to disable all the keys (make a button with instance name, my_btn, to make this work):
Actionscript Code:
my_btn.onPress = function(){ disableKeys(); // enableKeys(); }
Hope this helps
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|