Skip to main content
Participating Frequently
September 20, 2011
Question

Wrapping TextFlow around images and players

  • September 20, 2011
  • 2 replies
  • 2014 views

Hello,

I need to make Dynamic Wrapping for Text around Images and Players like videos or swfs.

I use RichEditableText component which use TextFlow component, but i can't do that till now.

what can i do ?

Thank you,

amt

This topic has been closed for replies.

2 replies

Adobe Employee
September 21, 2011

Image has no attribute to show its position, so it can be on the left edge and right edge, which is the “float” feature, or just regarded as a character, which is the “inline graphic”.

If you want to put image in the middle of texts, the method will be a little bit complex. You can just put it onto a separate sprite as follows.

You can make sprite 0-3 as linked containers. Then one textflow can flow from sprite 0 to sprite 3.

var cc0:ContainerController = new ContainerController(sprite0,200,100);

var cc1:ContainerController = new ContainerController(sprite1,200,100);

var cc2:ContainerController = new ContainerController(sprite2,200,100);

var cc3:ContainerController = new ContainerController(sprite3,200,100);

textFlow.flowComposer.addController(cc0);

textFlow.flowComposer.addController(cc1);

textFlow.flowComposer.addController(cc2);

textFlow.flowComposer.addController(cc3);

textFlow.flowComposer.updateAllControllers();

Because s:RichEditableText is also a sprite, you can add sprite 0-3 onto s:RichEditableText. 

amtamtAuthor
Participating Frequently
September 21, 2011

thank you very much for reply,


I tried and found this link about add images to TLF

http://help.adobe.com/en_US/flex/using/WS19f279b149e7481c2028ff4112df207af8b-8000.html

But, when i tried to use same mxml code for VideoPlayer insted of Image, an Error is done.

So, I tried your second reply about ContainerController and InlineGraphicElement and I could add Player to TLF.

The problems now are :

1- very bad alignment for this Player, may be because there is no "float" property at it, I don't know.

2- The player became non interactive Component, ONLY for Display and show, I can't click on its buttons to control it.

so, Can you help me please to solve this problems ?

Thank you,

amtamtAuthor
Participating Frequently
September 21, 2011

true try, make my VideoPlayer is White Area.

the output is :

code is:

var rc:RichEditableText = new RichEditableText( );

var ice3:InlineGraphicElement = new InlineGraphicElement( );

var pr:ParagraphElement = new ParagraphElement( );

var span:SpanElement = new SpanElement( );

span.text = "Flex";

  var vp:VideoPlayer = new VideoPlayer( );

  vp.source="rtmp://fmsexamples.adobe.com/vod/mp4:_cs4promo_1000.f4v";

  vp.width = 250;

  vp.height = 150;

  vp.addEventListener( Event.COMPLETE, vpCompleteHandler );

  vp.addEventListener( MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, vpMediaPlayerStateChangeHandler );

  ice3.source = vp;

  pr.addChild( span );

  pr.addChild( ice3 );

  rc.textFlow.addChild( pr );

    rc.textFlow.flowComposer.updateAllControllers( );

what can be that ?

Thank you,

Adobe Employee
September 21, 2011

The easiest way is to take advantage of "float" attribute, which is similar with HTML float layout. But the image will float to left or right. In TLF, image, video, swf can be embeded into textflow through InlineGraphicElement. You can feed InlineGraphicElement a URL or flash.display.DisplayObject. Sprite, Shape, and Flex Components are all extends from DisplayObject. But we CANNOT promise it will be shown if you embeded too many level of flex components as ILG and finally put textflow into a RichEditableText. Some flex components, such as RichEditableText, are based on TLF, but we are not developing those components. You may want to ask Flex team to confirm that.

• float<String>. Controls the placement of the graphic. The float property may have these values:

• none Graphic will appear inline with the text.

• left Graphic will appear to the left of the text, and the text will wrap around it.

• right Graphic will appear to the right of the text, and the text will wrap around it.

• start Graphic will appear on the leading edge of the text, and the text will wrap around it. The leading edge is the left if the direction of the paragraph is ltr, and the right if the direction is rtl.

• end Graphic will appear on the trailing edge of the text, and the text will wrap around it. The trailing edge is the right if the direction of the paragraph is ltr, and the left if the direction is rtl.

If a container has floats, and has verticalAlign=“justify”, the vertical justification will be ignored.

A float will appear at the same level as the line it is on if it can while maintaining the anchor in the line. If putting the float at the same level as the line (and thus wrapping the line around the float) would cause the anchor to get pushed out of the line, then the float appears below the line.

If the float width exceeds the column width it places the float anyway, and the float may either bleed over other content or be clipped. If the float height exceeds the column height, the float is pushed to the next column or container.

You can control how close the text and the image are by setting the padding properties of the img element. Setting the padding values causes the img element to be treated as slightly larger (or smaller if the padding is negative) than its width and height would indicate. Setting the paddingLeft of a left float will cause the float to be indented from the left edge, and setting the paddingTop causes it to get pushed down.