Skip navigation
Currently Being Moderated

list remove

Nov 10, 2010 8:03 AM

Is there any function to remove  the list?

// I can modify the list, but I don't know how to remove the list. it seems that there is no function  to remove

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                            xmlns:s="library://ns.adobe.com/flex/spark"
                            xmlns:mx="library://ns.adobe.com/flex/mx"
                            xmlns:ai="http://ns.adobe.com/ai/2009"
                            xmlns:d="http://ns.adobe.com/fxg/2008/dt"
                            xmlns:flm="http://ns.adobe.com/flame/2008"
                            creationComplete="initApp()">
     <fx:Script>
          <![CDATA[
               import flashx.textLayout.BuildInfo;
               import flashx.textLayout.compose.IFlowComposer;
               import flashx.textLayout.compose.TextFlowLine;
               import flashx.textLayout.conversion.TextConverter;
               import flashx.textLayout.edit.IEditManager;
               import flashx.textLayout.edit.SelectionFormat;
               import flashx.textLayout.edit.SelectionState;
               import flashx.textLayout.elements.FlowGroupElement;
               import flashx.textLayout.elements.ListElement;
               import flashx.textLayout.elements.ListItemElement;
               import flashx.textLayout.elements.ParagraphElement;
               import flashx.textLayout.elements.SpanElement;
               import flashx.textLayout.elements.TextFlow;
               import flashx.textLayout.formats.ITextLayoutFormat;
               import flashx.textLayout.formats.ListMarkerFormat;
               import flashx.textLayout.formats.ListStylePosition;
               import flashx.textLayout.formats.ListStyleType;
               import flashx.textLayout.operations.SplitParagraphOperation;
               
               import spark.components.TextArea;
               import spark.utils.TextFlowUtil;
               
               protected function initApp():void {
                    var version:String = "";
                    version += "TLF version: " + BuildInfo.VERSION + "<br/>"+"TLF Build number: " + BuildInfo.kBuildNumber;
                    var s:String = "";
                    s += "<TextFlow version='2.0.0' xmlns='http://ns.adobe.com/textLayout/2008'>";
                    s += "<p>Flex framework"+version+"</p>";
                    s += "<p>Flex is a free, open source framework for building highly interactive, expressive web applications that dep</p>";
                    s += "<p>Flex framework</p>";
                    s += "<p>Flex framework</p>";
                    s += "<p>I am a new paragraph and I'd like to start at the left below the image</p>";               
                    s += "</TextFlow>";
                    messageTA.textFlow = TextConverter.importToFlow(s, TextConverter.TEXT_LAYOUT_FORMAT);
               }
 
               protected function doSetList():void
               {
                    var interactionManager:IEditManager = messageTA.textFlow.interactionManager as IEditManager;
                         
                    var selStart:int=interactionManager.anchorPosition
                    var selFinish:int=interactionManager.activePosition
                    interactionManager.selectRange(selStart,selFinish)
                         
                    var lm:ListMarkerFormat=new ListMarkerFormat();
                    lm.listStyleType=ListStyleType.CHECK;
                    lm.tabStops="e20 s24";
                    lm.listStylePosition=ListStylePosition.INSIDE;
                    lm.paragraphEndIndent=5;     
                         
                    interactionManager.createList(null,lm)
 
               }
               private function ClearAllFormats():void{
                    var interactionManager:IEditManager = messageTA.textFlow.interactionManager as IEditManager;
                    
                    var selStart:int=interactionManager.anchorPosition
                    var selFinish:int=interactionManager.activePosition
                    //interactionManager.selectRange(selStart,selFinish);
                    //interactionManager.selectAll();
                    
                    //interactionManager.moveChildren()
                    var sState:SelectionState=new SelectionState(messageTA.textFlow,selStart,selFinish)
                    //interactionManager.setSelectionState(sState)
                    
                    var fontF:ITextLayoutFormat=interactionManager.getCommonCharacterFormat()
                    var paraF:ITextLayoutFormat=interactionManager.getCommonParagraphFormat()
                    var conF:ITextLayoutFormat=interactionManager.getCommonContainerFormat()
                    
                    interactionManager.clearFormat(fontF,paraF,conF,sState)
               }
          ]]>
     </fx:Script>
     <s:VGroup left="5"
                 right="5"
                 top="10"
                 bottom="82">
          <s:Button label="Set List At cursor position"
                      click="doSetList()"/>
          <s:Button label="ClearAllFormat"
                      click="ClearAllFormats()"/>
          <s:TextArea id="messageTA"
                         width="100%"
                         height="100%"
                         editable="true"/>
     </s:VGroup>
     
</s:WindowedApplication>

I use clearformat function , but do nothing.........

What's more , if i want do following :

format["listStyleType"]=ListStyleType.NONE

will get an error:

ArgumentError: Error #2004: One of the parameters is invalid.
     at Error$/throwError()
     at flash.text.engine::TextBlock/createTextLine()
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at GlobalSWFContext/callInContext()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:2221]
     at flashx.textLayout.compose::BaseCompose/createTextLine()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:892]
     at flashx.textLayout.compose::ComposeState/createTextLine()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\ComposeState.as:410]
     at flashx.textLayout.compose::ComposeState/composeNextLine()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\ComposeState.as:352]
     at flashx.textLayout.compose::BaseCompose/composeParagraphElementIntoLines()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:711]
     at flashx.textLayout.compose::BaseCompose/composeParagraphElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:608]
     at flashx.textLayout.compose::ComposeState/composeParagraphElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\ComposeState.as:297]
     at flashx.textLayout.compose::BaseCompose/composeBlockElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:317]
     at flashx.textLayout.compose::BaseCompose/composeBlockElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:331]
     at flashx.textLayout.compose::BaseCompose/composeBlockElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:322]
     at flashx.textLayout.compose::BaseCompose/composeBlockElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:331]
     at flashx.textLayout.compose::BaseCompose/composeBlockElement()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:322]
     at flashx.textLayout.compose::BaseCompose/composeInternal()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:593]
     at flashx.textLayout.compose::ComposeState/composeInternal()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\ComposeState.as:143]
     at flashx.textLayout.compose::BaseCompose/composeTextFlow()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\BaseCompose.as:410]
     at flashx.textLayout.compose::ComposeState/composeTextFlow()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\ComposeState.as:106]
     at flashx.textLayout.compose::StandardFlowComposer/http://ns.adobe.com/textLayout/internal/2008::callTheComposer()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\StandardFlowComposer.as:678]
     at flashx.textLayout.compose::StandardFlowComposer/internalCompose()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\StandardFlowComposer.as:762]
     at flashx.textLayout.compose::StandardFlowComposer/updateToController()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\StandardFlowComposer.as:558]
     at flashx.textLayout.compose::StandardFlowComposer/updateAllControllers()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\compose\StandardFlowComposer.as:519]
     at flashx.textLayout.edit::EditManager/updateAllControllers()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:774]
     at flashx.textLayout.edit::EditManager/handleUpdate()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:805]
     at flashx.textLayout.edit::EditManager/finalizeDo()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:640]
     at flashx.textLayout.edit::EditManager/doOperation()[C:\Vellum\dev\output\openSource\textLayout\src\flashx\textLayout\edit\EditManager.as:589]

Thanks.

 
Replies
  • Currently Being Moderated
    Nov 10, 2010 3:33 PM   in reply to diding w

    Yes.  There is a new function on IEditManager moveChildren that can take the contents out of a list and move it somewhere else.

     

    Hope that helps,

    Richard

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 12, 2010 12:26 AM   in reply to diding w

    If you look at the EditManager API, you'll see a function called moveChildren. This can be used to "promote" the child of a list; essentially what would happen if the user typed a shift-TAB.

     

    This should promote the children of a listItem, to be children of the list's parent:

     

         var target:FlowGroupElement = listItem.parent.parent;

         var targetIndex:int = target.getChildIndex(listItem.parent);

         editManager.moveChildren(listItem, 0, listItem.numElements, target, targetIndex);

     

    I haven't tested this exact code, but something like this should work. So try looping through the children of the list, and doing this to each one. Note that this sample code assumes that the children of a ListElement are ListItemElements, but they could be paragraphs... in which case you'll probably want to promote the child of the ListElement, and not its grandchild. That's a special case not handled by this snippet.

     

    - robin

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 10, 2012 11:57 AM   in reply to diding w

    Thanks for this post from a long time ago. Am just getting around to TLF now and was struggling with lists.  Thanks!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points