0 Replies Latest reply on Nov 23, 2009 2:19 PM by mikelchristian_h

    [Flash Builder 4] span + div ID of actual selection

    mikelchristian_h

      Hi,

       

      how can i get with the SelectionManager/EditManager the actual style-id from a selection?

       

      e.g. this is the textflow-text: "<div><span id="bar" fontSize="20" fontWeight="bold" fontStyle="italic" backgroundColor="0xdddddd">bar</span></div>"

       

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="initApp()">
           
           
           <fx:Script>
                <![CDATA[
                     import flashx.textLayout.conversion.TextConverter;
                     import flashx.textLayout.edit.EditManager;
                     import flashx.textLayout.edit.SelectionManager;
                     import flashx.textLayout.elements.TextFlow;
                     
                     public var text:String
                     public var textFlow:TextFlow
                     public var em:EditManager
                     public var sm:SelectionManager
                     
                     
                     private function initApp():void {
                          text = '<TextFlow xmlns="http://ns.adobe.com/textLayout/2008"><div><span id="bar" fontSize="20" fontWeight="bold" fontStyle="italic" backgroundColor="0xdddddd">bar</span></div></TextFlow>'
                          
                          textFlow = TextConverter.importToFlow(text, TextConverter.TEXT_LAYOUT_FORMAT);
                          textFlow.interactionManager = new SelectionManager();
                          textFlow.interactionManager = new EditManager();
                          
                          em = textFlow.interactionManager as EditManager;
                          sm = textFlow.interactionManager as SelectionManager
                          
                          rt.content = textFlow;     
                     }
                     
                     
                     private function selectFunction():void {
                          
                          /* Hier möchte ich die span id "bar" auslesen */
                          trace(sm.getCommonCharacterFormat().fontWeight)                    
                     }
                     
                     
                ]]>
           </fx:Script>
           
           
           <s:Button x="127" y="80" label="Button" id="selectBtn" click="selectFunction()"/>
           <s:RichEditableText x="35" y="181" text="RichEditableText" width="215" height="167" id="rt"/>
           
           
      </s:Application>