Groups | Blog | Home
all groups > flash actionscript > august 2005 >

flash actionscript : FocusManager question


tillurdizzy
8/29/2005 10:21:44 PM
I have a situation where I need to clear the tabIndex and enter in a new one.
What seems to be happening is the second tabIndex is ADDED TO the index, rather
than replacing it, so TABbing just jumps back and forth between the two "1"
indexes.

Setting a different component to tab order 1 did not replace the current one.

So, the question is, how do I clear the tabIndex so it will accept a whole new
set?
FlashTastic
8/29/2005 10:34:39 PM
Only buttons, textFields, and movieClips have a tabIndex property.
According to the MM docs, tabIndex is undefined by default.

Have you tried creating an array of the instance names of the items you want
to tab through, and then manually assigning them a tabIndex number? I was
having the same problem before so I did this and it seemed to work fine.

code:

var itemsToTab = ["button1_mc","button2_mc","textField1_tf","textField2_tf"]

for (var j =0;j<itemsToTab.length;j++){
itemsToTab[j].tabIndex = j;
}

I know there's probably a hundred solutions out there better than this, so
anyone with a better solution feel free... hope it helps.


Cheers,
FlashTastic


tillurdizzy
8/29/2005 10:50:06 PM
Hi FlashTastic,

I am setting them like this:
See Code Sample One.

But then I want to change it when a mc, set off stage initially, is brought on
the stage:
See Code Sample Two.

The first function is called when the movie starts. The second is called when
a button is clicked.

As I said before, the second one is not replacing he first, so it just toggles
back and forth between the two "1" settings.

//ONE

function setMainMenuTabs() {
textOne_ti.tabIndex = 1;
textTwo_ti.tabIndex = 2;
textThree_ti.tabIndex = 3; // etc. etc...
}

//TWO

function setMcTabs() {
mc.textOne_ti.tabIndex = 1;
mc.textTwo_ti.tabIndex = 2;
mc.textThree_ti.tabIndex = 3; // etc. etc...
}
tillurdizzy
8/29/2005 11:14:18 PM
I Answer My Own Question...

I kept trying to clear the FocusManager with one command:

FocusManager.tabIndex = undefined // which did not work

You must clear each component instance that you have assigned a tabIndex to
individually.

myInputText_ti.tabIndex = undefined; //etc.

Then, you can define new ones. There is no single tabIndex list... each
component stores its own... so setting a new one to the same value does not
replace the old one.
FlashTastic
8/29/2005 11:19:49 PM
Okay,

I understand what you mean now... sorry 'bout the last post.

The tabIndex property is a property of the movieclip and not a global property,
so assigning a different movieclip to tabIndex = 1, will not change the old
movieclip's tabIndex property. In theory you could have an unlimited number of
clips with tabIndex = 1.

You'll have to reset the old clips' tabIndex to null or undefined before
setting your new clips' tabIndex.

Does that make sense?

Cheers,
FlashTastic











FlashTastic
8/29/2005 11:20:32 PM
Seems that you answered your question while I was answering your question..!

tillurdizzy
8/30/2005 1:13:29 AM
FlashTastic:
I might want your help (paid, of course).. I will get back to you tomorrow.
FlashTastic
8/30/2005 7:57:47 PM
I might be able to help..

Send me an e-mail offlist to flashtastic [at] gmail [dot] com.

Cheers,
AddThis Social Bookmark Button