Skip to main content
Participant
August 31, 2009
Question

Selection problem???

  • August 31, 2009
  • 2 replies
  • 1756 views

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()      at flashx.textLayout.edit::SelectionManager$/http://ns.adobe.com/textLayout/internal/2008::computeSelectionIndex()      at flashx.textLayout.edit::SelectionManager/selectionPoint()      at flashx.textLayout.edit::SelectionManager/setNewSelectionPoint()      at flashx.textLayout.edit::SelectionManager/handleMouseEventForSelection()      at flashx.textLayout.edit::SelectionManager/mouseMoveHandler()      at flashx.textLayout.container::ContainerController/mouseMoveHandler()      at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::rootMouseMoveHandler()

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....

This topic has been closed for replies.

2 replies

September 2, 2010

Hi all,

I am facing a real problem here related to what you are talking about , only difference is that i use sparks textArea.

i have this bug , that is a bot hard to reproduce  that gives me the same error msg as above.

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at flashx.textLayout.edit::SelectionManager$/computeSelectionIndexInContainer()

at flashx.textLayout.edit::SelectionManager$/http://ns.adobe.com/textLayout/internal/2008::computeSelectionIndex()

at flashx.textLayout.edit::SelectionManager/selectionPoint()

at flashx.textLayout.edit::SelectionManager/http://ns.adobe.com/textLayout/internal/2008::setNewSelectionPoint()

at flashx.textLayout.edit::SelectionManager/handleMouseEventForSelection()

at flashx.textLayout.edit::SelectionManager/mouseMoveHandler()

at flashx.textLayout.container::ContainerController/mouseMoveHandler()

at flashx.textLayout.container::TextContainerManager/mouseMoveHandler()

at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::rootMouseMoveHandler()

the exact line that it falls on is
localX -= textLine.x;
where textLine is null, this happends when i some variations of mouse clicks and selecting text , could be between lines, i am not really sure on how exactly to reproduce.
also , i dont know if this is related but the selection is not working right , when i am selecting the text it does not show the selectable blue background but if i copy and paste etc. it is working. but dont know if this is related.
thanks in advance.

Adobe Employee
September 2, 2010

Hi,

Not sure - probably need a reproducible example - we're not seeing these issues here.  I'm thinking that the selection not drawing (does it work sometimes?) indicates you've modified the TextFlow but havent' updated the TextLines.  As above can you verify that model changes are followed by a call to updateAllControllers before retutnring control to FlashPlayer for rendering and events.

TLF doesn't do this automatically for you - the idea is that while the update is expensive model changes are cheap, users can do many model changes and when they're done a single update.

Richard

Known Participant
August 31, 2009

HI,

I was not tested your code, but this problem seems similar to the one I had (see this thread). A fix has been made in the build number 500+. The latest sources code on the svn fixes a number of errors related to text selection.

Hoping to help

Fabien

poloopAuthor
Participant
September 1, 2009

Hi,

Thank you for your reply, I found the solution to my problem without upgrading the tlf framework. I changed the textFlow's format without update the controllers.

With the sentence :

_textFlow.flowComposer.updateAllControllers();

just after : _textFlow.paddingLeft = 20;

my problem was solved.

Thanks.