December 2003


When modifying a tree through its model, the change (selection changed) event won’t always fire as it should. For example, if you delete the currently selected node the selection will change to null but no change event will be dispatched. In cases like this you have to dispatch the change event manually using the component’s dispatchEvent method. For example:

tree.dispatchEvent({target:tree, type:"change"});

In general it’s best to use the event dispatching framework to manually fire the event from the component as shown here as opposed to just invoking the handler(s) directly. That way you don’t have to worry about keeping track of what handlers are listening to the component. Also, manually invoking a handler will cause the handler code to see a different value for “this” than if the handler had been invoked by the event framework, which may produce unexpected results.

When using an embedded font with a custom TextFormat, remember that the embedFonts property of the text field to which the TextFormat is being applied must be set to true. The property defaults to false, so just setting the format of a TextField to a TextFormat containing an embedded font isn’t sufficient for the embedded font to be used.

For example:

var tfmt = new TextFormat();
tfmt.font = "MyEmbeddedFontSymbol";
myTextField.embedFonts = true; // < -- critical!
myTextField.setTextFormat(tfmt);

This also applies to fonts set through style properties. For example, if we have something like

_global.style.setStyle("fontFamily", "MyEmbeddedFontSymbol");

intended to set the global fontFamily style property for all components to use a custom font symbol, it’s necessary to set the embedFonts property as well:

_global.style.setStyle("embedFonts", true);

Without the above line, the specified font symbol will not be used in components as desired.

When changing the filter function on a DataSet, it is necessary to set the filtered property to false and then true again in order for the proper modelChanged event to be fired. Just changing the filterFunc property won’t cause the event to be fired.

Also, if there’s already a filter in place when the data loads in (modelChanged/updateAll), the filter won’t be applied until filtered is set to false and then back to true again (even if on immediately successive lines).