Annoying Obscure Flash Bugs Episode 2: The Phantom Caret

(Yes, yes, I know the phantom menace was episode 1, but this is my second annoying obscure Flash bug of the week, and 'Attack of the Ghosting Caret Clones' didnt have quite the same ring to it)

Well, I've just wasted THREE HOURS trying to work around a stupid stupid bug in Macromedia Flash MX Version 6. The problem was that when I used the Selection.setFocus() method, a static non-functioning caret (a ghost caret, if you like) would appear in every TextField that I had, because they were stored in a MovieClip for ease of use. Not a big thing, you may think, but this is a pretty key component to my next 4 months work, so I kinda want to get it right, and ugly vertical lines all over my text fields didn't look very good. Think I've dropped enough keywords for google?

After three hours of trawling through google and google groups with various combinations of keywords, I came across one single post from 2002 in google groups (my new favourite place in the whole wide world) which said:

I've recently had exactly the same problem.
Awesome.

To fix it, I changed all of my TextField types from 'input' to 'dynamic'. That means you cannot type in them, so they cannot have the cursor any more. Cunning. However, they can have the focus, so when they get the focus, change them to an input so you can type. When they lose the focus, change it back to dynamic. If you've stumbled across this page trying to fix the same problem as me, I've recently had exactly the same problem. You may find the following code helpful:

myTextFieldName.onKillFocus = function() {

this.type = "dynamic";

}

myTextFieldName.onSetFocus = function() {

this.type = "input";

}

Now leave me a comment saying you found it useful! Have a nice day :)

Comments

Ahh, but you didn't stumble across the page after trying to fix the same problem as me, so you wouldn't! The instruction to comment is only for those people who find it through a search engine, probably in 2007 or something :)

Leela

And you wonder why I never comment on your journal!! It's not very accessible to normal people is it!!

Well this isn't a normal entry... think of it as more of a public service announcement!

I've been chasing the phantom caret for a couple of hours... found this with keywords "Selection lose focus actionscript bug", when it became apparent that there was some lameness with the textfields not losing focus...

Awesome! Glad I could be of some help :)

Leave a comment