Skip to main content
Participating Frequently
May 17, 2011
Answered

Several error #1009 occurrences w/ TLFTextField/TLF 2 in CS5.5

  • May 17, 2011
  • 1 reply
  • 2026 views

I'm currently working on a Flash application which formerly used plain old TextFields and has now been adapted to use TLFTextFields instead.

While I'm generally quite happy with some of the improvements in TLF 2 (lists!), it still seems much buggier than expected from Adobe.

For example, textHeight doesn't always seem to update immediately after setting htmlText, scrollV sometimes returned nonsensical values while scrolling, when re-setting htmlText some formatting (colors, font weight) from the previous value stays around etc. In short, even the new version of TLFTextField seems significantly less robust than TextField (which probably shouldn't come as a surprise, given the complexity of the thing).

While annoying, for most of those issues I was able to find work-arounds. Now, however, we're seeing rather mysterious null-pointer issues popping up.

Maybe those errors ring some bell with you; I'm sorry I can't provide more detailed information yet (I'm getting those reports from testers in the field).

A related question: Is there a 100% reliable way to reset a TLFTextField, so that no internal inconsistencies have any chance of staying around?

---

While querying numLines:

TypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.
    at flashx.textLayout.compose::BaseCompose/advanceToComposeStartPosition()
    at flashx.textLayout.compose::BaseCompose/composeTextFlow()
    at flashx.textLayout.compose::ComposeState/composeTextFlow()
    at flashx.textLayout.compose::StandardFlowComposer/http://ns.adobe.com/textLayout/internal/2008::callTheComposer()
    at flashx.textLayout.compose::StandardFlowComposer/internalCompose()
    at flashx.textLayout.compose::StandardFlowComposer/composeToPosition()
    at flashx.textLayout.container::TextContainerManager/http://ns.adobe.com/textLayout/internal/2008::getActualNumLines()
    at SingleTextContainerManager/get numLines()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/SingleTextContainerManager.as:183]
    at fl.text::TLFTextField/get numLines()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/TLFTextField.as:3323]
    at kp.ui.controls::TextScrollBar/get visibleLines()[/Users/chris/r/2010/09/kp-maintenance-2010-11/flash-5/kp/ui/controls/TextScrollBar.as:119]

---

When setting htmlText:

ypeError: Error #1009: Der Zugriff auf eine Eigenschaft oder eine Methode eines null-Objektverweises ist nicht möglich.

   at flashx.textLayout.compose::FlowComposerBase/addLine()

   at flashx.textLayout.compose::ComposeState/endLine()

   at flashx.textLayout.compose::BaseCompose/composeParagraphElementIntoLines()

   at flashx.textLayout.compose::BaseCompose/composeParagraphElement()

   at flashx.textLayout.compose::ComposeState/composeParagraphElement()

   at flashx.textLayout.compose::BaseCompose/composeBlockElement()

   at flashx.textLayout.compose::BaseCompose/composeInternal()

   at flashx.textLayout.compose::ComposeState/composeInternal()

   at flashx.textLayout.compose::BaseCompose/composeTextFlow()

   at flashx.textLayout.compose::ComposeState/composeTextFlow()

   at flashx.textLayout.compose::StandardFlowComposer/http://ns.adobe.com/textLayout/internal/2008::callTheComposer()

   at flashx.textLayout.compose::StandardFlowComposer/internalCompose()

   at flashx.textLayout.compose::StandardFlowComposer/composeToPosition()

   at flashx.textLayout.container::TextContainerManager/http://ns.adobe.com/textLayout/internal/2008::getActualNumLines()

   at SingleTextContainerManager/get numLines()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/SingleTextContainerManager.as:183]

   at fl.text::TLFTextField/get maxScrollV()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/TLFTextField.as:3135]

   at fl.text::TLFTextField/set scrollV()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/TLFTextField.as:3723]

   at fl.text::TLFTextField/http://ns.adobe.com/textLayout/internal/2008::doImport()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/TLFTextField.as:1365]

   at fl.text::TLFTextField/set htmlText()[/Volumes/BuildDrive/stage/Flash11.5_Main_325_Stage/main/authortool/Stage/tlfRuntime/fl/text/TLFTextField.as:2705]

   at kp.ui.windows::BubbleWindow/set text()[/Users/chris/r/2010/09/kp-maintenance-2010-11/flash-5/kp/ui/windows/BubbleWindow.as:84]

This topic has been closed for replies.
Correct answer Gang Cai

Thanks again!

Ideally, TLFTextField should be usable with minimal knowledge of the complexities of the TLF.

That properties like textWidth return wrong values until after the CompositionCompleteEvent has fired is extremely unexpected.

"I am not quite sure what you mean about immediate."

I want (for example) the following to work reliably:

tlfTextField.htmlText = ...;

otherUIComponent.width = tlfTextField.textWidth;

otherUIComponent is some other display object which has a (visual) dependency on the tlfTextField (e.g. a background sprite).

According to this blog post, I would have to listen for a CompositionCompleteEvent first and then register an ENTER_FRAME handler:

     http://www.oscar-mejia.com/blog/post/tlf-resiable-textflow-container

Is this really the recommended/simplest way to do it?


I would say yes. The codes shown in the blog are necessary for that scenario.

The example in the link I gave you last time may be another good example if you do not need the resizing operation as shown in the blog's example.

TLF is designed to handle the complex text layout things. We need to make sure it works for almost every client's scenario and handle hundreds of text properties. We can make it eaiser to get one or two properties easier in some specific scenario(i.e. static text's TextWidth) but that will make the framkework more complex and less flexible(i.e. danamic text's TextWidth can't be gotten that way because it may be changed from time to time). I think most Rich Text editor faces the same problem. Personally, I think the TLF is a nice solution.

Whatever, We appreciate very much your advice. We'll consider your advice in the future.

1 reply

Participating Frequently
May 18, 2011

Hi

I am not quite sure what the real problem you met as I don't get your code sample...

Basically, You should operate the TLFTextField's TextFlow after the ADDED_TO_STAGE event is triggered and get the information such as textHeight after the COMPOSITION_COMPLETE event is triggered. You can add the COMPOSITION_COMPLETE event handler for TLFTextField as the following way:

public function test()

{

// constructor code

super();

addEventListener(Event.ADDED_TO_STAGE,display);

}

private function display(evt:Event):void

{

txtFlow = testText.textFlow;

txtFlow.addEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, compositionCompleteHandler);

}

For the set Html issue, I think you should post your html samples here so that we can identify what the real problem is.

Thanks

chl_Author
Participating Frequently
May 18, 2011

Hey, thanks a lot for the quick reply!

If values like textHeight can't be trusted until after the COMPOSITION_COMPLETE event, you should _definitely_ mention that in the TLFTextField documentation.

Is there a way to _force_ immediate composition, so that I know _without_ listening to COMPOSITION_COMPLETE that the values can be trusted?

As for the HTML issue, I think my testers might have identified the problem; I'll get back to you ASAP.

Participating Frequently
May 18, 2011

Hi

The documents about TLF should be found in the document for the TextLayout package. i.e. The document for the CompositionCompleteEvent shoulde be at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/events/CompositionCompleteEvent.html. You can search the adobe online help for more details.

The composition process is triggered whenever the text has been changed. Each text container has two states: composition and display. The text property is supposed to be changed in the composition state as we are working on layout composition things in that stage. The CompositionCompleteEvent notifies you when the composition phase has ended. The trusted properties or the appropriate changes are designed to be gotten or set after you enter the display stage. I am not quite sure what you mean about immediate. But under my understanding, listening the CompositionCompleteEvent is the most immediate way to know the proper properties.

Hope these information is helpful.

Thanks