First of all: thanks to all who replied! This is a great list.

Various solutions were proposed, from overlays (graphics, movieclip or invisible button) to TextField with scrollbar. However, the best solution in my case, was from Muzak, with his specialized TextArea class. Man, thanks, you saved my day: text cannot be copied and yet, URL's embedded in the text, can still be activated.


Sample code and Muzaks' class MyTextArea are provided to whom it may need:
(hopefully still readable despite the format of the list)

Peter van der Post

// class MyTextArea - a read-only TextArea:
package {
        
        import fl.controls.TextArea;
        import flash.text.TextFieldType;

        public class MyTextArea extends TextArea {
                
                private var _selectable:Boolean = true;

                public function MyTextArea()    {
                        super();
                }
                
                override protected function updateTextFieldType():void {
textField.type = (enabled && _editable) ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
                        textField.selectable = _selectable;
                        textField.wordWrap = _wordWrap;
                        textField.multiline = true;
                }
                
                public function get selectable():Boolean {
                  return _selectable;
                }
                
                public function set selectable(value:Boolean):void {
                  _selectable = value;
                  super.textField.selectable = value;
                  updateTextFieldType()
                }
                
        } // endof class
} // endof package


// Document class for a TestTextArea.fla - Read-Only TextArea
// FLA-file does contain TextArea component in Library, but none at the stage

package {
        import flash.display.Sprite;

        public class TestTextArea extends Sprite {
                public var details2_ta:MyTextArea;
                public function TestTextArea () {
                        super ();
                        details2_ta = new MyTextArea();
                        details2_ta.editable = false;
                        details2_ta.selectable = false; // this does the trick!
                        details2_ta.width = 200;
                        details2_ta.height = 200;
                        details2_ta.x = 200;
                        details2_ta.y = 200;
                        addChild (details2_ta);
                        showSample2 ();
                }

                private function showSample2 () {
                        var blueColorFont:String = "<FONT COLOR='#0000FF'>";
                        var BREAK:String = "<BR>";
                        var endFont:String = "</FONT>";
var msg:String = "<b>Lorem ipsum dolor sit amet,</b> consectetuer adipiscing elit.";
                        var webURL:String = "www.macnn.com/";
var details:String = "<u><a href='http://"; + webURL + "'> " + blueColorFont + webURL + endFont + "</a></u>";
                        details2_ta.htmlText = msg + BREAK + details;
                }
        }
}


On Fri, Mar 27, 2009 at 4:38 PM,  <pe...@pepo.nl> wrote:

I'll have to prevent users to copy text from a TextArea. In Flex I saw you do that bij setting a selectable attribute of the mx.controls.TextArea to
false.

However, this seems not possible with the fl.controls.TextArea, which is
used in Flash CS4 / AS3.

Does someone has a tip or hint.
Thanks.

PS. setting editable of the TextArea to false doesn't help, and setting the enabled attribute of the TextArea to false gives a disabled look and is
not the intention.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to