Copy link to clipboard
Copied
I have a FLASH Main Web Site Navigation Menu that has (7) Buttons (actual BUTTON objects created in Flash - not MovieClips) that load different HTML pages. Everything is working perfect (rollover states, linking, etc.), but I cannot figure out how to write the AS3.0 code to create a "Button Disabled" State? I have seen some code snippets that talk about this if using MovieClips, but how can I make a "Button" disable after clicking?
I assume that I would need a variable that would capture and retain the last button clicked?
Any help would be greatly appreciated as I keep coming up against this same issue.
Here is my current code that makes the buttons work:
var mainButtons:Array = new Array(mainBtn0,mainBtn1,mainBtn2,mainBtn3,mainBtn4,mainBtn5,mainBtn6);
var mainButtonsURLs:Array = new Array("http://www.thekentcompanies.com/Pages/index.html", "http://www.thekentcompanies.com/Pages/WhatsNew.html", "http://www.thekentcompanies.com/Pages/Facebook.html", "http://www.thekentcompanies.com/Pages/Golf.html", "http://www.thekentcompanies.com/Pages/Motorsports.html", "https://thekentcompanies.tms.hrdepartment.com/cgi-bin/a/searchjobs_quick.cgi", "http://www.thekentcompanies.com/Pages/Register.html");
function loadMainPageToFrame(event:MouseEvent):void {
var count:Number = mainButtons.length;
var index:Number;
for (var i:Number =0; i<count; i++) {
if (event.target.name == mainButtons.name) {
var myURL:URLRequest = new URLRequest(mainButtonsURLs);
navigateToURL(myURL, "_self");
}
}
}
for (var i:Number = 0; i<mainButtons.length; i++) {
mainButtons.addEventListener(MouseEvent.CLICK, loadMainPageToFrame);
// mainButtons.mouseChildren = false;
}
It's a link to a source file, so at most you'll see a window asking what you want to do with it. You may have to right click to get an option to save the targeted file.
Copy link to clipboard
Copied
If you are talking about SimpleButton objects, then you have some ability to control their states but you can't add a disabled state. You might be able to create the impression of one, but you really would make it easier for you to manage if you use movieclips instead of buttons.
Here's a link to a sample file that makes use of the different button state properties (new to AS3) to realize a disabled button.
http://www.nedwebs.com/Flash/AS3_Disable_Btns.fla
The disabled graphic is defined in the Hit state frame. The problem you run into is losing a particular state when you change it, so you need some object around as a reference to restore it. For this example I just use the other button's state for this, but if your buttons have labels that differ, then this won't work for you.... you'd probably need a second set of buttons, but if you go with movieclips you can avoid this juggling of states.
Copy link to clipboard
Copied
Not able to se anything at that link?
Copy link to clipboard
Copied
It's a link to a source file, so at most you'll see a window asking what you want to do with it. You may have to right click to get an option to save the targeted file.
Copy link to clipboard
Copied
Ned, I just saw your file.
You're basically using the mouseEnabled thing, but, if I'm not wrong, this should work with movieClips too.
For example, if you have a movieClip you could use:
//to enable the movieClip...
btn_mc.buttonMode = true;
btn_mc.mouseEnabled = true;//to disable the button just change the second lineCode to false.
I don't know if I understood what the OP wants but an option (more of a hack) would be to have a transparent movieClip over the last used button (setting its x/y property to the current x/y of the last clicked button?).
Well, I'm sure this is not the best way to do it, nor even a professional way, but could work if I understood what OP wants.
Copy link to clipboard
Copied
The mouseEnabled bit is just a side-product. What the file demonstrates is how to use the "...State" properties of the SimpleButton class... A new actionscript feature that would otherwise still have folks saying that you cannot do what the OP wanted using button symbols (some still will anyways). The cleaner /more manageable approach is to use movieclip symbols.
Copy link to clipboard
Copied
For some reason it was not downloading earlier, but I got it this time.
I think I can make this work for what I need.
Much thanks!!!
Copy link to clipboard
Copied
You're welcome.