Selection problem???
Hello,
I need some help, I don't understand what th problem. I create a TextFlow in an flex Application. I declare an InteractionManager, but when I try to select my text, the player give me an error :
Vellum: 470 (709639), Flex: 4.0.0.7219, Player: WIN 10,0,22,87
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
at flashx.textLayout.edit::SelectionManager$/computeSelectionIndexInContainer()
Bellow the code in my mxml file :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cp="com.mazarine.project.view.components.*"
layout="absolute"
creationComplete="init()" horizontalAlign="center" verticalAlign="middle" xmlns:ns1="com.mazarine.textEditorModule.views.components.*">
<mx:Script>
<![CDATA[
import flashx.textLayout.BuildInfo;
import mx.core.Container;
import com.mazarine.textEditorModule.ApplicationFacade;
import com.mazarine.textEditorModule.views.*;
import nl.demonsters.debugger.MonsterDebugger;
import com.utils.textLayout.CSSFormatResolver;
import flashx.textLayout.conversion.TextConverter;
import flash.text.engine.TextLine;
import flash.text.engine.TextBlock;
import flash.text.engine.TextElement;
import flash.text.engine.ElementFormat;
import flash.text.engine.FontDescription;
import flash.text.engine.FontLookup;
import flashx.textLayout.edit.IEditManager;
import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.elements.FlowElement;
import flashx.textLayout.formats.ITextLayoutFormat;
import flashx.textLayout.edit.ElementRange;
import flashx.textLayout.edit.SelectionState;
import nl.demonsters.debugger.MonsterDebugger;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextFilter;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.edit.EditManager;
import flashx.undo.UndoManager;
import flashx.textLayout.conversion.ConversionType;
import flashx.textLayout.container.TextContainerManager;
public static const NAME : String = 'TextEdidorModule'; // Warning used in PopUpManager do not change......
private var facade : ApplicationFacade = ApplicationFacade.getInstance(NAME);
private var _debug : MonsterDebugger = new MonsterDebugger(this);
private function init() : void {
//facade.startup(this);
////////////////////////////////////////
var textContent : String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>" +
"<p><span styleName='titre'>TITLE</span></p>" +
"<p><span styleName='body'>Header</span></p>" +
"<p><span styleName='body'>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </span><a href='http://www.google.com'><span styleName='link'>HELLO WORLD!</span></a> <span styleName='body'>Phasellus nec lorem odio, nec porttitor ante. Suspendisse eget ante magna, feugiat iaculis ligula. Nulla vitae tortor vitae nulla eleifend tristique. Aenean pellentesque gravida consequat. Morbi pellentesque mauris nibh, vitae ultrices est. Donec non velit neque.</span></p>" +
"<p><a href='http://www.google.com'><span styleName='link'>HELLO WORLD!</span></a></p>" +
"</TextFlow>";
TextFlow.defaultConfiguration.unfocusedSelectionFormat = TextFlow.defaultConfiguration.focusedSelectionFormat;
var _container : Sprite = new Sprite();
var _controller : ContainerController = new ContainerController(_container,500,400)
textArea.rawChildren.addChild(_container);
var _textFlow : TextFlow = TextConverter.importToFlow(textContent, TextConverter.TEXT_LAYOUT_FORMAT);
_textFlow.flowComposer.addController(_controller);
// make _textFlow editable with undo
_textFlow.interactionManager = new EditManager(new UndoManager());
// initialize with a selection before the first character
_textFlow.interactionManager.selectRange(0,0);
_textFlow.flowComposer.updateAllControllers();
_textFlow.interactionManager.setFocus();
//_textFlow.formatResolver = new CSSFormatResolver();
_textFlow.paddingTop = 30;
_textFlow.paddingLeft = 20;
var infoVersion : String = "Vellum: " + flashx.textLayout.BuildInfo.kBuildNumber + ", Flex: " + mx_internal::VERSION + ", Player: " + Capabilities.version;
trace(infoVersion);
}
]]>
</mx:Script>
<mx:Canvas id="textArea" width="520" height="400" x="10" y="90"/>
<!--<ns1:EditorPanel id="editor" x="10" y="308">
</ns1:EditorPanel>-->
<!--<ns1:TextPanel id="textPanel">
</ns1:TextPanel>-->
</mx:Application>
Thank you very much for your help....
