Scroll Bar Does not work
Hi I've took the example from http://corlan.org/2009/02/12/how-to-add-a-scrollbar-to-text-layout-framework/ to add a scroll bar to my editor
I use TextLayout Framework 2 and SDK Version 3.5 so I had to adapt my code to work and I got stuck on
private function composeListener(event:CompositionCompletionEvent):void {
var textHeight:int = Math.ceil(_controller.calculateHeight());
if (textHeight < _controller.compositionHeight) {
scroll.enabled = false;
} else {
scroll.enabled = true;
scroll.minScrollPosition = 0;
scroll.maxScrollPosition = textHeight - _controller.compositionHeight;
}
_controller.verticalScrollPosition = 0;
TLF 2 & SDK 3.5 Forces me to use a ContainerController that doesn't have a calculateHeight method.
How can I adapt this code to work with my current code? Is there an updated example of this?
Also here is my set textFlow method that might be helpful.
public function set textFlow(newFlow:TextFlow):void { // clear any old flow if present if (_textFlow) { _textFlow.flowComposer = null; _textFlow = null; } _textFlow = newFlow; if (_textFlow) {
//textArea - Canvans _controller = new ContainerController(_container,textArea.width,textArea.height); _controller.verticalScrollPolicy = ScrollPolicy.ON; _textFlow.flowComposer.addController(_controller); // setup event listeners for selection changed and ILG loaded _textFlow.addEventListener(SelectionEvent.SELECTION_CHANGE,selectionChangeListener,false,0,true); _textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE,graphicStatusChangeEvent,false,0,true); _textFlow.addEventListener(FlowOperationEvent.FLOW_OPERATION_BEGIN,operationBeginHandler); _textFlow.addEventListener(CompositionCompleteEvent.COMPOSITION_COMPLETE, composeListener); _textFlow.addEventListener('scroll', scrollTextFlow); // make _textFlow editable with undo _textFlow.interactionManager = new EditManager(new UndoManager()); // initialize with a selection before the first character _textFlow.interactionManager.selectRange(0,0); // compose the new textFlow and give it focus _textFlow.flowComposer.updateAllControllers(); _textFlow.interactionManager.setFocus(); } }
Thank you
