hey frnds,
i'm using simple TLF editor where user can add image in it.
my code is
var textFlow:TextFlow = new TextFlow();
var p:ParagraphElement = new ParagraphElement();
img = new InlineGraphicElement();
img.source = relativePath+addPopupIMG.filePath;
img.height = 100;
img.width = 100;
p.addChild(img);
textFlow.addChild(p);
var tf:String = TextConverter.export(textFlow,
TextConverter.TEXT_LAYOUT_FORMAT,
ConversionType.STRING_TYPE).toString();
Now i want tht user can select this image in my TLF Editor and can resize its width and height.
Is any way there to change selected image from TLFEditor ?
thx in advanced,
![]()
TLF provides a ModifyInlineGraphicOperation that is used in the demo TextLayoutEditor project in the GRAPHICS tab on the bottom. That can be used to modify a selected inlineGraphic by entering new width/height values. TLF isn't providing any UI that allows a user to select an inlineGraphic, get drag handles and resize the image. Nothing stopping you from writing that - you'll want to intercept events on the ContainerController.
Hope that helps,
Richard
I would suggest adding an EditManager as the interactionManager of the TextFlow:
textFlow.interactionManager = new EditManager();
This will enable selection by clicking and dragging. You will need some sort of button or other gesture so the user can change the size of the graphic that is selected. When you detect that gesture, you can use the interactionManager to do the operation:
textFlow.modifyInlineGraphic(img.source, newWidth, newHeight, ...)
This will change the amount of space left for the image. If you want to change the image itself (e.g., to resize it or change its appearance), you would do that operation on the img.source before calling modifyInlineGraphic. Or you could pass an entirely different DisplayObject to modifyInlineGraphic, and it would apply the new one in place of the old one.
Hope this helps,
- robin
I have used the insertInlineGraphic of Editmanager class to insert the images in the TextArea control. its working fine. when we selects the image, i need to display the url of the image in another textarea control.. how can i get the image path when user selects the image in the TLF..?
Code i have used :
IEditManager(textFlow.interactionManager).insertInlineGraphic(imgPath ,imgWidth,imgHeight);
Thanks in advance,
karthikeyan.cs.
Get the InlineGraphicElement by textflow.findLeaf(textflow.interactionManager.getSelectionState().anc horPosition) as InlineGraphic;
and then get its attribute *source*
textflow.interactionManager = new EditManager() when you get null object
package
{
import flash.display.Sprite;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.*;
public class FindLeaf extends Sprite
{
public function FindLeaf()
{
var markup:String = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"+
"<TextFlow xmlns=\"http://ns.adobe.com/textLayout/2008\">"+
"<p><span>Te</span><img source=\"http://www.adobe.com/include/img/truste_seal_eu.gif\" width=\"116\" height=\"33\"/></p>"+
"</TextFlow>";
var textFlow:TextFlow = TextConverter.importToFlow(markup,TextConverter.TEXT_LAYOUT_FORMAT);
var cc:ContainerController = new ContainerController(this, 1000,1000);
textFlow.flowComposer.addController(cc);
textFlow.flowComposer.updateAllControllers();
var leaf:FlowLeafElement= textFlow.findLeaf(2);
trace((leaf as InlineGraphicElement).source);
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific