Tab-key/FocusRect Disabling - Help!

I forgot the actionscript but what I wanted to do is disable the yellow focus rectangle that comes up on a button when the tab key is pressed. Now, thats easy:

[AS]buttonname._focusrect = false[/AS]

Ok but how do I disable it for everysingle button in the whole movie? And where do I put this actionscript? In the first keyframe?

I think the action script may have to do with proto or prototype, I don’t wanna ask people on Newgrounds how to do it. Thanx.

yea thats the right syntax, you can put it on a blank keyframe, or where there is already code. i think you can put all ur buttons in a an array and just say

myArray._focusrect = false

[AS]for (name in _root) {
if (typeof (_root[name]) == “object”) {
_root[name]._focusrect = false;
}
}[/AS]i think this will disable focus on all button + textfields + objects in _root
:-\

Wait claudio…what do I put in for [name] ??? Its for the whole movie, not a button or movie clip.

Just paste that code on first frame of your main timeline

Tried it…doesnt work. The rect still appears.

As i said, that will only disable focus if the objects are in _root.

isnt there an easier way? i know theres a code for it, its like 1 line long and it works.

[AS]Button.prototype.tabEnabled = false;[/AS]

Kax, that will exclude the button in automatic tab ordering.
He wants to disable the yellow focus rectangle.
:-\

… Do you really think I don’t know that!? :stuck_out_tongue:

The thing is,
[AS]Button.prototype._focusrect = false;[/AS]
doesn’t work. :-\

[AS]MovieClip.prototype.allowFocus = function(act) {
for (var counter in this) {
if (this[counter].proto == Button.prototype) {
this[counter]._focusrect = act;
} else if (this[counter].proto == MovieClip.prototype && this[counter]._parent == this) {
this[counter].allowFocus(act);
}
}
};
ASSetPropFlags(MovieClip.prototype, “allowFocus”, 7);
allowFocus(false);[/AS]

:stuck_out_tongue:

I was about to post this:
[AS]MovieClip.prototype.enableFocusRect = function() {
for (var prop in this) {
if (this[prop] instanceof MovieClip) {
this[prop].enableFocusRect(arguments[0]);
} else if (this[prop] instanceof Button) {
this[prop]._focusrect = arguments[0];
}
}
};
// example
_level0.enableFocusRect(false);[/AS]

Hey cladio - what do u mean thatll exclude the button in automatic tab ordering?

Hey kax…thanks a lot. The button.prototype.tabenable=false thingy works perfectly now. But you’re sure it works for everysingle button right? What about for buttons inside symbols, and buttons in other scenes?

Yes, the property will be disabled in every single Button object.

Thanks. BTW, whats all that other A.S. about?

There’s not much I can tell about it.

It’s a method that will loop through all the objects. If the object is a MovieClip, it will call the method; if the object is a Button, it will set to false (or true, depending on the parameter passed to the function (kind of obvious, isn’t it?)) its _focusrect property.

Pretty simple. :wink: