V2 FocusManager's Impact More Far Reaching than I Originally Thought
April 30, 2004

Looks like the FocusManager issue I pointed out previously has effects that go beyond just the realm of Flash. Nigel pointed out to me that my last post on V2 FocusManager has gone wacky on Flog. It looks like it's been included there like 50 times interspersed with other posts. I double checked my RSS feed, and it looks fine, so hopefully the posts get removed and people don't flame me.

Sorry, but I can't think of any fixes for this one...

[Update]

Apparently, it had to do with the type of apostrophe that I used in the post. I wrote up the post in Word and pasted it into MT which caused the use of the smart quote instead of the regular apostrophe. Anyway, it's been fixed and so the posts should stop appearing now. Thanks to Dave Humphreys for the tip.

Posted by philter at 01:31 PM | Comments Disabled
V2 FocusManager's Impact on Daedalus and Maybe Your Next Project Too!
April 29, 2004

One of my first orders or duty in coming over to work for Grant has been to contribute to Daedelus, a project we'll be releasing in the coming weeks (sounds mysterious, doesn't it ;) While in the process of coding parts of it, I ran across an issue which had me completely stumped for a couple of hours. After trying everything I could think of, I noticed that the behavior was only manifesting itself when I was using a Macromedia (MM) V2 component in the same file.

From what I can tell, this issue could potentially have serious ramifications on any project that uses a V2 component in combination with plain movieclips and buttons.

So here's the deal…my scenario had my Flash movie dropping click events, kinda reminiscent of what Grant described in a blog entry way back. However, in this case, it isn't a random occurance and it doesn't depend on processor strain. It turns out that there is a specific situation where clicks get dropped.

One of the really cool features of MM's V2 component set is that it's got strong focus management, so that components can receive and lose focus via clicks or key events. Unfortunately, this is the cause of the problem. Ever notice that if you use say, a TextArea component, and you select some text in it, then use the scroll thumb to scroll the text, when you release the thumb, the selection magically restores itself? Yeah, that's pretty cool. Well, it seems that this magic happens primarily via mx.managers.FocusManager. Basically, all it does is store the beginIndex and endIndex of the selected textfield when the mouse is pressed (oh, and did you know that if you use the V2 components, every onMouseDown, onMouseUp, and onMouseMove event has code that runs on those events?) and restore the selection on release. Sounds nice, but there is one major issue that arises. It seems that somewhere in the code that does all of this, something occurs that prevents onPress and onRelease events from being fired if a textfield has focus.

Here is an example…

If you look at the first example, you can click on the text field at the right and then click the blue button a few times without moving your mouse (frequency of clicks doesn't matter) and you notice that all click events fire properly (onPress in this case).






Then, in the second example (identical to the first, except this one has an MM button component on the stage – it doesn't actually do anything), if you set focus to the textfield and then try clicking the blue button, again without moving your mouse, all of a sudden, it doesn't fire all of the onPress events properly (it only fires a new event when you click after moving your mouse to a new position).






After hunting through some of the component code, I noticed that UIComponent actually contains 2 methods, pressFocus and releaseFocus that all onPress and onRelease handlers should call respectively. In fact, it seems that all MM's components do call these, and so if you click on any MM component while a textfield is focused, you don't have these same issues (if you click on the MM button in the example 2 above, you'll see that the blue button reponds properly thereafter). That's fine and dandy if you are writing classes that inherit from UIComponent, but what if you just want to create a simple movieclip or button. In these cases, it seems that if a textfield has focus, this bug will pretty much always manifest itself.

The very quick way to circumvent this bug is to just call:

Selection.setFocus(this);

from inside your onPress handler. This will remove focus from the textfield and your onPress and onRelease events won't be dropped. The following example adds this one line of code.






If you were clever, you could even write some code to save the selection and restore it onRelease (kinda like what MM does).

Does this affect your project? If you're using any MM components in your app, you can do this simple test:

Click on a textfield (any textfield) in your movie and then click on any NON-MM component (i.e., any movieclip or button that has an onPress or onRelease event), cross your fingers and check the results…

Posted by philter at 08:30 AM | Comments Disabled
Off to go work for the gMan (Grant Skinner)
April 19, 2004

Well, today is the big day...I recently turned down a great offer at the government job I was working so I could pursue what I feel is an even better opportunity. So today, I start working for the gDude himself...Mr. Grant Skinner.

Most of you who've been involved in the Flash community over the past year or so are probably well aware that Grant has proven himself to be one of the top Flash developers out there. His accolades include:

  • Winning 2 awards at FlashForward and 1 at FlashInTheCan, along with several more nominations
  • Speaking at numerous conferences and running a very successful Flash course (Flash MX2004 Enterprise Development) in Edmonton, Toronto, and London, England in May.
  • Developing gModeler v1.0 (a Flash based UML class diagramming tool). For all of you who've been asking about it, now that I'm on board, he says he'll have a little more free time to develop v2.0 in the near future:)

I'm very excited to be working with Grant as it will provide the opportunity to work on some great projects, as well as collaborate with, and learn from a guy I have a ton of respect for.

If you're interested, Grant has posted some info on the type of work we'll be offering, and will be posting our CV's on his site shortly.

Posted by philter at 09:32 AM | Comments Disabled