Skip to main content
Inspiring
February 26, 2009
Answered

TextFlow and Controller Being Created Too Early?

  • February 26, 2009
  • 1 reply
  • 596 views
I've successfully rolled my work with the TextFlow into a Canvas component, made it into an SWC, and made that part of the application it was originally designed for. No problems. Alright, now time to re-use my work in another app. that could benefit from a rich text component. Went through the usual motions and got all of my UI for my text component to render except the TextFlow!

Then what I discovered is when I resized the browser window that hosting my Flex app, the cascade of resize events got the TextFlow to finish rendering, the scroll bars got adjusted properly, and it was ready to accept input with the blinking cursor.

Here is a dump from some trace statements I have in my code, I'm trying to work out the order in which events are happening and when the text flow gets proper measurements:

Composer -> Resize -> New TextFlow Dimensions -> W: 0 H: 0
Composer -> Creating Display Controller -> TextFlow Dimensions -> W: 754 H: 0
Composer -> Created
MessageEditorBase -> Created
MessageEditorBase -> Event Fired -> Resize
MessageEditorBase -> Event Fired -> Show
Composer -> Resize -> New TextFlow Dimensions -> W: 754 H: 0
MessageEditorBase -> Event Fired -> Resize
Composer -> Resize -> New TextFlow Dimensions -> W: 1328 H: 274
MessageEditorBase -> Event Fired -> Resize
Composer -> Resize -> New TextFlow Dimensions -> W: 1328 H: 275
MessageEditorBase -> Event Fired -> Resize
Composer -> Resize -> New TextFlow Dimensions -> W: 1329 H: 276
MessageEditorBase -> Event Fired -> Resize
Composer -> Resize -> New TextFlow Dimensions -> W: 1334 H: 277
MessageEditorBase -> Event Fired -> Resize
Composer -> Resize -> New TextFlow Dimensions -> W: 1350 H: 279

"MessageEditorBase" is a canvas (used as a tab) that gets displayed to the user. Within that Canvas are lots of components including the "Composer" which is basically a toolbar of elegant buttons and format functions, and then a blank canvas which holds a UIComponent and becomes the DisplayObjectController. Works great in my other app, the code is nearly line for line with Adobe's examples.

Notice how it starts 0,0; then gets a width measurement of 754; finally when I the user resize the entire application do the rest of the proper dimensions get computed.

I don't think it's a TextFlow problem, but I can't say I understand the Flex rendering hierarchy enough to have implemented TextFlow and its controller in the right way with this app.

Any thoughts? If you need more information just ask and I'll try to explain as best as possible.

This topic has been closed for replies.
Correct answer mrapcznski
As it turns out with a lot of fiddling and trace statements, I figured out a way to initialize the DisplayObjectController with valid pixel values. In your TLF examples, the developers always created a display object controller using specific dimensions, like 250 x 250. But I need my text component to be created dynamically based on the screen size of the user. This was not happening correctly after I upgraded to TLF build 370, though it's not even a TLF problem.

I took the measurements from the parent canvas. For whatever strange reason, in the world of measuring Flex components, the child canvas further down in the application, the one that I added the sprite to, was not getting measured out correctly. Thus when I passed the controller width and height values from this child, they were 0.

I hope that made sense, but either way, problem fixed.

Edit:

Here's an example of my code using a custom controller that had the keyDown event overriden:

theController = new ComposerDisplayController(uiFlowComponent, uiTextArea.width, uiTextArea.height, this);

I passed values which I expected the UI to measure out rather than me providing explicit pixel values. I had a problem when the UI gave me zero.

1 reply

brian_thomas2
Adobe Employee
Adobe Employee
March 6, 2009
If you haven't already, you should post this to the Flex Forums as well. You may get some more flex-related ideas there.

I am having trouble understanding exactly what the problem is. Screenshots and code snippets would be especially helpful.
mrapcznskiAuthorCorrect answer
Inspiring
March 9, 2009
As it turns out with a lot of fiddling and trace statements, I figured out a way to initialize the DisplayObjectController with valid pixel values. In your TLF examples, the developers always created a display object controller using specific dimensions, like 250 x 250. But I need my text component to be created dynamically based on the screen size of the user. This was not happening correctly after I upgraded to TLF build 370, though it's not even a TLF problem.

I took the measurements from the parent canvas. For whatever strange reason, in the world of measuring Flex components, the child canvas further down in the application, the one that I added the sprite to, was not getting measured out correctly. Thus when I passed the controller width and height values from this child, they were 0.

I hope that made sense, but either way, problem fixed.

Edit:

Here's an example of my code using a custom controller that had the keyDown event overriden:

theController = new ComposerDisplayController(uiFlowComponent, uiTextArea.width, uiTextArea.height, this);

I passed values which I expected the UI to measure out rather than me providing explicit pixel values. I had a problem when the UI gave me zero.