Skip to main content
Participant
August 3, 2010
Question

After I apply a hyperlink to a textArea,delete it throw error

  • August 3, 2010
  • 2 replies
  • 1100 views

Applying url code is here:

      var editManager:IEditManager = this.textArea.textFlow.interactionManager as IEditManager;

      var tlf: TextLayoutFormat= this.textArea.getFormatOfRange(null,beginIndex,endIndex);

     editManager.applyLink(value.toString(),"_blank");
      tlf["color"] = 0x18479B;
      tlf["textDecoration"] = TextDecoration.UNDERLINE;
      this.targetTextArea.getTextFlow().interactionManager.setFocus();

    

After I delte , throw these error:

   TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flashx.textLayout.elements::FlowLeafElement/computeElementFormat()
at flashx.textLayout.elements::FlowLeafElement/http://ns.adobe.com/textLayout/internal/2008::createContentElement()
at flashx.textLayout.elements::SpanElement/http://ns.adobe.com/textLayout/internal/2008::createContentElement()
at flashx.textLayout.elements::FlowLeafElement/http://ns.adobe.com/textLayout/internal/2008::setParentAndRelativeStart()
at flashx.textLayout.elements::FlowGroupElement/replaceChildren()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at flashx.textLayout.elements::SubParagraphGroupElement/replaceChildren()
at flashx.textLayout.elements::FlowGroupElement/deepCopy()
at flashx.textLayout.elements::FlowGroupElement/deepCopy()
at flashx.textLayout.elements::FlowGroupElement/deepCopy()
at flashx.textLayout.edit::TextFlowEdit$/createTextScrap()
at flashx.textLayout.operations::DeleteTextOperation/doOperation()
at flashx.textLayout.edit::EditManager/doInternal()
at flashx.textLayout.edit::EditManager/doOperation()
at flashx.textLayout.edit::EditManager/deletePreviousCharacter()
at flashx.textLayout.edit::EditManager/keyDownHandler()
at flashx.textLayout.container::ContainerController/keyDownHandler()
at flashx.textLayout.container::TextContainerManager/keyDownHandler()
at spark.components.supportClasses::RichEditableTextContainerManager/keyDownHandler()

This topic has been closed for replies.

2 replies

aoxiang_yAuthor
Participant
August 6, 2010

I use Flex 4.1 ,Thanks for your help , I used what you have writen upstairs Application, almost the same as What I have writen a applicaiton. But when I delete text with hperlink, still throw error,I donn't know why?

Adobe Employee
August 5, 2010

I've been unable to reproduce this in TLF 1.1 or 1.0. I wrote the following small application, based on your post. Can you look over it and tweak it and see if you can get it to show the problem? Also, are you using Flex 4.0 or 4.1? Thanks!

- robin

Adobe Employee
August 5, 2010

Sorry, here's the application:

<s:Application name="gandhi"
               xmlns="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:flow="library://ns.adobe.com/flashx/textLayout"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               viewSourceURL="srcview/index.html" creationComplete="applyLink()">
   
    <Script><![CDATA[
        import flashx.textLayout.events.FlowElementMouseEvent;  
        import mx.controls.Alert;
        import flashx.textLayout.formats.TextLayoutFormat;
        import flashx.textLayout.formats.TextDecoration;
        import flashx.textLayout.edit.IEditManager;
       
       
        public function applyLink():void
        {
            var editManager:IEditManager = this.textArea.textFlow.interactionManager as IEditManager;
           
            var tlf: TextLayoutFormat= this.textArea.getFormatOfRange(null,0,5);
           
            editManager.selectRange(1, 4);
            editManager.applyLink("www.adobe.com" ,"_blank");
            tlf["color"] = 0x18479B;
            tlf["textDecoration"] = TextDecoration.UNDERLINE;
            this.textArea.textFlow.interactionManager.setFocus();
        }
    ]]></Script>
   
    <mx:VBox
        width="100%"
        height="100%"
        paddingLeft="10"
        paddingRight="10"
        paddingTop="10"
        paddingBottom="10">
       
        <mx:HBox id="box"
                 width="100%"
                 height="100%"
                 paddingLeft="10"
                 paddingRight="10"
                 paddingTop="10"
                 paddingBottom="10">
           
            <s:TextArea id="textArea" verticalScrollPolicy="off"
                        textAlign="justify"
                        width="30%"
                        height="100%">
                <s:content>      
                    <s:div fontFamily="Minion Pro" fontSize="14" paddingLeft="10" paddingRight="10">
                        Hello World
                    </s:div>
                </s:content>
            </s:TextArea>
           
           
        </mx:HBox>
    </mx:VBox>
   
</s:Application>