2 Replies Latest reply on Dec 18, 2009 9:05 AM by Gregory Lafrance

    Flex 3 RichTextEditor - move controlbar to top

    Gregory Lafrance Level 6

      I want to move the controlbar of the RichTextEditor above the TextArea instead of the default of being below the TextArea.

       

      I've been playing around with it as follows but I have a feeling I should not do this in the updateDisplayList method.

       

      Should I do it in the initialize method?

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:RichTextEditor xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Script>
          <![CDATA[
            import mx.controls.TextArea;
            import mx.core.UIComponent;
            
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
              var txt:TextArea = TextArea(super.removeChild(textArea));
              var cb:DisplayObject = DisplayObject(super.removeChild(this.controlBar as DisplayObject));
              super.addChild(cb);
              super.addChild(new TextArea());
              super.updateDisplayList(unscaledWidth, unscaledHeight);
            }
          ]]>
        </mx:Script>
      </mx:RichTextEditor>
      
      
        • 1. Re: Flex 3 RichTextEditor - move controlbar to top
          Gregory Lafrance Level 6

          This doesn't work either:

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:RichTextEditor xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="setupUI();">
            <mx:Script>
              <![CDATA[
                import mx.controls.TextArea;
                import mx.core.UIComponent;
                
                private function setupUI():void{
                  var taIndex:uint;
                  var cbIndex:uint;
                  for(var a:uint=0;a<this.rawChildren.numChildren;a++){
                    trace(this.rawChildren.getChildAt(a));
                    if(a==2){
                      var disObj:DisplayObject = this.rawChildren.removeChildAt(a);
                      this.rawChildren.addChildAt(disObj, 1);
                    }
                  }
                  trace("**************************");
                  for(var b:uint=0;b<this.rawChildren.numChildren;b++){
                    trace(this.rawChildren.getChildAt(b));
                  }
                }
              ]]>
            </mx:Script>
          </mx:RichTextEditor>
          
          
          • 2. Re: Flex 3 RichTextEditor - move controlbar to top
            Gregory Lafrance Level 6

            Hats off to Wally Kolcz of the Flex Coders Yahoo group for this simple answer.

            http://tech.groups.yahoo.com/group/flexcoders/message/150883

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:RichTextEditor xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" initialize="init()">
                <mx:Script>
                    <![CDATA[
                        import flash.display.DisplayObject;
                        public function init():void {
                            var displayObj:DisplayObject = this.toolbar;
                            this.toolbar.parent.removeChild(displayObj);
                            this.addChildAt(displayObj, 0);
                        }
                    ]]>
                </mx:Script>
            </mx:RichTextEditor>