Archive for the ‘Flex Gotchas’ Category

ButtonBar radio logic hack

September 30, 2011 Leave a comment

Update: Set the requireSelection property to true.

When the button bar is used as a navigation tool for a set of tabs, it doesn’t make sense for the selected button to be unselected if the user clicks on it.

It is also fairly typical for a result handler of the IndexChangeEvent.CHANGED to utilize the button bar’s selectedItem property to access a piece of data. This causes runtime errors when the selected item is no longer selected because of a re-click on the selected button.

Read more…

Flex 4 <s:Rect/> height limit of 10,000?

In my post about vertical scroll speed I show a code example of a scroller with several nested groups. A typical design of websites these days is to have a content area in the middle with an ever-expanding height and some sort of repeating background or colors on the sides – Just look at the layout of the majority of blogs, including my own.

Writing a flex app with the same design where you can scroll a lot of content vertically with a solid background color is a pretty typical use-case, but you will quickly find a limitation with using the primitive class Rect as a background: maxHeight = 10,000.

Read more…

SkinnableTextBase focusManager runtime error popup

May 5, 2011 4 comments

When you show a popup in Flex in a mobile environment, defined as the style “interactionMode” being set to InteractionMode.TOUCH in this context, that is based on a component that does not implement the mx.managers.IFocusManagerContainer interface, you will receive a runtime error when the user taps the control that is to receive focus.

Lets pretend you have a custom component that is based on <s:Group/>:

Read more…

Making sure your air application exits (?:when using ApplicationUpdater(?:UI)?)?

December 30, 2010 Leave a comment

One of our desktop applications had the requirement of providing an auto-update feature. We turned to the built in framework of ApplicationUpdaterUI to fill that requirement, but interestingly enough the form would sometimes not show at all after calling initialize and then our application wouldn’t actually exit when the main window was closed by the user and no other windows were visible.

The symptom of the application not exiting was because I was listening for the INITALIZED and ERROR events on the application updater with weak references and no other references to the updater existed. Thus, sometimes, the updater UI wouldn’t show up at all. Despite the form not showing up sometimes, the native window was actually created, so when the main window closed, the application didn’t actually exit and had to be shut down via the OS (e.g. task manager/force quit) – ouch.

Once I realized what was going on and added strong referenced listeners, I could still make the problem occur by simply closing the application updater UI dialog or by pressing the cancel button – stupid.

Read more…

Object/Dictionary Reference counting and Memory Management

March 7, 2010 Leave a comment

Since it is such an important topic and such a problem for the community, I thought I would make another post pertaining to optimizing for the garbage collector.

I was looking for information in the object/dictionary docs completely unrelated to memory management, but ran across this statement:

As long as any reference to the object exists, the garbage collection system will not recover the memory that the object occupies. If the value of myObject is changed such that it points to a different object or is set to the value null, the memory occupied by the original object becomes eligible for garbage collection, but only if there are no other references to the original object.


Yes, you do need to explicitly set all non-simple types to null and splice/delete array indices and hash key entries.

Read more…

Unknown error generating output application.xml files

January 15, 2010 Leave a comment

I’ve been implementing a new project using the TDD methodology using some of the new flash builder tools – specifically the “Execute FlexUnit Tests” method when you right click on a test case class.

When the project matured enough to check into SVN, I noticed a weird error:

Unknown error generating output application.xml files.

Read more…

assertEquals using != and the difference between != and !==

January 4, 2010 Leave a comment

When using the assertEquals method in Flexunit 4, it is important to understand how the != operator works.

I was under the assumption that != checked the values of the items on either side of the operand, while the !== checked the reference, but != checking values is only partially true.

Read more…