Richard, thanks for the sample. The problem will be apparent if you attach the TLF within a ScrollPane. I've modified the Alice code (below). Kindly take a view... you might need to keep a ScrollPane in the library of the FLA.
//========================================================================================
//
// ADOBE CONFIDENTIAL
//
// Copyright 2007-2010 Adobe Systems Incorporated. All rights reserved.
//
// NOTICE: All information contained herein is, and remains
// the property of Adobe Systems Incorporated and its suppliers,
// if any. The intellectual and technical concepts contained
// herein are proprietary to Adobe Systems Incorporated and its
// suppliers, and are protected by trade secret or copyright law.
// Dissemination of this information or reproduction of this material
// is strictly forbidden unless prior written permission is obtained
// from Adobe Systems Incorporated.
//
//========================================================================================
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.utils.ByteArray;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.events.UpdateCompleteEvent;
import flashx.textLayout.elements.TextFlow;
import fl.containers.ScrollPane;
import fl.controls.ScrollPolicy;
public class Alice extends Sprite
{
[Embed(source="alice.xml",mimeType="application/octet-stream")]
private var AliceClass : Class;
private var sp:ScrollPane;
public function Alice()
{
if (stage)
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
}
/* [Shiyaz:] I need to create the TLF within a ScrollPane,
* so the sprite 's' is supplied as source to the sp.
* */
sp = new ScrollPane();
sp.move(100, 100);
sp.setSize(500 + 20, 400);
sp.verticalScrollPolicy = ScrollPolicy.AUTO;
sp.horizontalScrollPolicy = ScrollPolicy.OFF;
var s:Sprite = new Sprite();
//s.x = 100;
//s.y = 100;
//addChild(s);
var alice:ByteArray = new AliceClass();
var aliceData:String = alice.readMultiByte(alice.length,"utf-8");
// version doing a direct flowComopser
var textFlow:TextFlow = TextConverter.importToFlow(aliceData, TextConverter.TEXT_LAYOUT_FORMAT);
// version doing a direct flowComopser
//textFlow.flowComposer.addController(new ContainerController(s, 500, 400));
/* [Shiyaz:] If NaN is not used, the scrollpane content height will not be acquired
* Is there any other way to fix this?
* */
textFlow.flowComposer.addController(new ContainerController(s, 500, NaN));
textFlow.addEventListener(UpdateCompleteEvent.UPDATE_COMPLETE, tlfUpdtHandler, false, 0, true);
textFlow.interactionManager = new EditManager();
textFlow.flowComposer.updateAllControllers();
sp.source = s;
addChild(sp);
}
private function tlfUpdtHandler(e:Event):void
{
var textFlow:TextFlow = e.currentTarget as TextFlow;
var containerController:ContainerController = textFlow.flowComposer.getControllerAt(0) as ContainerController;
trace("update",containerController.getContentBounds());
textFlow.flowComposer.composeToPosition();
trace("fullCompose", containerController.getContentBounds());
try {
/* [Shiyaz:] This is the problem. When I type, the composeToPosition
* is not visible since the scrollpane is not updated to the current line.
* */
sp.update();
}catch (err:Error) {
trace("err:", err);
}
}
}
}