Wednesday, November 7, 2007

Use customize Style when initializing the app

I read this somewhere, if you want to use your own style while the app is initializing, you need to use initialize='onInitialize()'; when the application is initializing...

Tuesday, November 6, 2007

Make sure your CSS stylesheet is loaded before using measureWidth

I ran into a situation that when I apply a style class and need to retrieve the measuredWidth or textWidth for calculating component's properties.

I figured out we need to use validateNow(); to update the component's properties.
However, somehow the figures are kinda different on same component.

When I look close at the debugger, I found this line which is suspective:


Execute event: [Event type="" bubbles=false cancelable=false eventPhase=2]
animals: 57,26
[SWF] assets\css\main.swf - 3,196,972 bytes after decompression
Execute event: [Event type="" bubbles=false cancelable=false eventPhase=2]
animals: 73,28


I found that the Style sheet are not loaded before I moved to next step for checking measuredWidth, and here is the official solution:

var myEvent:IEventDispatcher =
StyleManager.loadStyleDeclarations('assets/css/main.swf');
myEvent.addEventListener(StyleEvent.COMPLETE, onLoadComplete);