Skip to main content
Participating Frequently
May 27, 2010
Answered

Insert ComboBox in Text Layout Framework(TLF)

  • May 27, 2010
  • 1 reply
  • 1870 views

Hi Everyone,

Anyone worked with Text Layout Framework (TLF)???

Please help me. I am facing a big problem.

As per TLF with the help of "insertInlineGraphic" method we can add Image or DisplayObject in TLF. But this is not happening. I am trying to add a combobox in TLF but no use.

Here is the line of code:

EditManager(_textFlow.interactionManager).insertInlineGraphic(new ComboBox(),100,40);

Please help me.

Regards,

Amandeep Singh

This topic has been closed for replies.
Correct answer robin_briggs

Hi Robin,

I tried this but of no help. It always give me x:0 and y:0 irrespective of image position in TextFlow.

Here is the code that I tried:

private function graphicStatusChangeEvent(evt:StatusChangeEvent):void

{

     if(evt.status == InlineGraphicElementStatus.READY)

     {

          _textFlow.flowComposer.updateAllControllers();

          var inlineGraphic:InlineGraphicElement = _textFlow.findLeaf(evt.element.getAbsoluteStart()) as InlineGraphicElement;

          Alert.show("x : " + inlineGraphic.graphic.x + "\ny : " + inlineGraphic.graphic.y);

     }

}

Regards,

Amandeep Singh


Sorry, you are right. The inline has a parent which handles its positioning. So when you look at the x, y, its 0 relative to its parent. If you were to look at the parent DisplayObject's position, you'd see what it is relative to the TextLine.

To get it in global (stage) coordinates, call globalToLocal() on the (x,y) position of the inline. To get it in coordinates relative to the line, you'd need to take the global coordinates and call textLine.localToGlobal, for the container relative coordinates it would be the same, but use the container instead of the textLine.

Hope this helps,

- robin

1 reply

Adobe Employee
May 27, 2010

Flex components don't support being parented by non-Flex components.  You could try and position a graphic that matches your flex component's size and then listen for TextFlow updateComplete events, find your graphic and then reposition the Flex component over it.  Haven't tried that though.

Richard

Participating Frequently
June 7, 2010

Hi Richard,

Thanks for your response.

Can you suggest me a way how to get the position (x, y) of the graphic element.

Regards,

Amandeep Singh

Adobe Employee
June 8, 2010

You can get the InlineGraphicElement that was inserted this way:

var inlineGraphic:InlineGraphicElement = textFlow.findLeaf(insertedPos) as InlineGraphicElement;

where "insertedPos" is the absolute text position where the inline was inserted. Given the ILG, you can get the DisplayObject, e.g.:

inlineGraphic.graphic.x

Hope this helps,

- robin