Packagecom.doitflash.text
Classpublic class TextArea
InheritanceTextArea Inheritance TF Inheritance flash.text.TextField

TextArea class is basically an extension of Adobe's TextField class and tries to complete the shortcomings of it. With the TextArea class you can do everything that you could do with the original TextField plus many more new features that will make your text blocks a lot more flexible and will make your flash project look way more professional.

With this class you have a new property, fmlText for displaying your text scripts. FML stands for Flash Markup Language. when using this property rather than the regular htmlText, it will allow you to:

View the examples

See also

TagLibrary
http://www.doitflash.com/


Public Properties
 PropertyDefined By
 InheritedassetsPath : String
TF
 Inheritedbase : Object
TF
 Inheritedclient : Object
Indicates the class instance where The TextArea class will look into to find public functions allowed to be called by the External scripts inside the TextArea
TF
 Inheriteddata : Object
TF
 InheritedflashVars : Object
TF
  fmlText : String
to use the potential poweres of TextArea you should use this property to inject your scripts into TextArea.
TextArea
  funcSecurity : Boolean
Specifies if the security on allowed functions to be called from text blocks is tight or loos.
TextArea
 Inheritedholder : Object
TF
 Inheritedid : int
TF
  mouseRollOverEnabled : Boolean
set this property to true before trying to catch rollOver/rollOut events for your href links. For performance reasons, we have set the default value to false
TextArea
  rolledOverText : String
[read-only] if property mouseRollOverEnabled is set to true, you will have access to this property which indicates the string link that your mouse is over it.
TextArea
  rolledOverUrl : String
[read-only] if property mouseRollOverEnabled is set to true, you will have access to this property which indicates the URL of the string that your mouse is over it.
TextArea
 InheritedserverPath : String
TF
 Inheritedxml : XML
TF
Protected Properties
 PropertyDefined By
 Inherited_assetsPath : String
TF
 Inherited_base : Object
TF
 Inherited_client : Object
TF
 Inherited_data : Object
TF
 Inherited_flashVars : Object
TF
 Inherited_holder : Object
TF
 Inherited_id : int
TF
 Inherited_serverPath : String
TF
 Inherited_xml : XML
TF
Public Methods
 MethodDefined By
  
when working with the TextArea class to create text blocks, just do what you normally used to do with the original TextField class.
TextArea
  
allowedFunctions(... rest):void
Use this function to list all the allowed functions to be called from TextArea for security reasons, it is highly recommendad to set the funcSecurity property to true, and use this method to pass in the allowed functions whom will be granted with the permission to be called from functions inside the text blocks.
TextArea
  
getModule($id:String):Object
By passing the id of the text-in-line module, this method returns the that module.
TextArea
  
getModuleLoader($id:String):Loader
By passing the id of the text-in-line module, this method returns the Loader of that module.
TextArea
Events
 Event Summary Defined By
  Defined by the original TextField classTextArea
  Defined by the original TextField classTextArea
  dispatches when a text-in-line module loads into the TextArea.TextArea
  Defined by the original TextField classTextArea
  Defined by the original TextField classTextArea
Property Detail
fmlTextproperty
fmlText:String

to use the potential poweres of TextArea you should use this property to inject your scripts into TextArea. rather than the classic htmlText or text properties which were defined by the original TextField class.


Implementation
    public function get fmlText():String
    public function set fmlText(value:String):void
funcSecurityproperty 
funcSecurity:Boolean

Specifies if the security on allowed functions to be called from text blocks is tight or loos. if set to false, any public function in the client of the TextArea instance can be accessed from the text blocks.

The default value is true.


Implementation
    public function get funcSecurity():Boolean
    public function set funcSecurity(value:Boolean):void

See also

mouseRollOverEnabledproperty 
mouseRollOverEnabled:Boolean

set this property to true before trying to catch rollOver/rollOut events for your href links.

For performance reasons, we have set the default value to false

The default value is false.


Implementation
    public function get mouseRollOverEnabled():Boolean
    public function set mouseRollOverEnabled(value:Boolean):void
rolledOverTextproperty 
rolledOverText:String  [read-only]

if property mouseRollOverEnabled is set to true, you will have access to this property which indicates the string link that your mouse is over it.


Implementation
    public function get rolledOverText():String

See also

rolledOverUrlproperty 
rolledOverUrl:String  [read-only]

if property mouseRollOverEnabled is set to true, you will have access to this property which indicates the URL of the string that your mouse is over it.


Implementation
    public function get rolledOverUrl():String

See also

Constructor Detail
TextArea()Constructor
public function TextArea()

when working with the TextArea class to create text blocks, just do what you normally used to do with the original TextField class. all you have to remember about TextArea is first that you will call fmlText property rather than htmlText to insert your script into it and second is the fact that you will need to set the path to the assets folder where you will have your .swf text-in-line modules.

Method Detail
allowedFunctions()method
public function allowedFunctions(... rest):void

Use this function to list all the allowed functions to be called from TextArea for security reasons, it is highly recommendad to set the funcSecurity property to true, and use this method to pass in the allowed functions whom will be granted with the permission to be called from functions inside the text blocks.

Parameters

... rest — rest

getModule()method 
public function getModule($id:String):Object

By passing the id of the text-in-line module, this method returns the that module.

Parameters

$id:String — this is the id attribute of your module tag.

Returns
Object — the text-in-line module.
getModuleLoader()method 
public function getModuleLoader($id:String):Loader

By passing the id of the text-in-line module, this method returns the Loader of that module.

Parameters

$id:String — this is the id attribute of your module tag.

Returns
Loader — Loader object of the module.
Event Detail
change Event
Event Object Type: flash.events.Event.CHANGE
CHANGE.type property = flash.events.Event.CHANGE

Defined by the original TextField class

link Event  
Event Object Type: flash.events.TextEvent.LINK
LINK.type property = flash.events.TextEvent.LINK

Defined by the original TextField class

onModuleLoaded Event  
Event Object Type: com.doitflash.text.events.TextInLineEvent
TextInLineEvent.type property = com.doitflash.text.events.TextInLineEvent.MODULE_LOADED

dispatches when a text-in-line module loads into the TextArea. checkout the TagLibrary class to see the supported tags. when listening to this event, you will have access to the module that has caused the event and also its id.

     function onModuleLoaded(e:TextInLineEvent):void
     {
         trace(e.param.module); // reference to the loaded swf file of the module
         trace(e.param.id); // outputs the id attribute of the loaded module
     }
     

See also

scroll Event  
Event Object Type: flash.events.Event.SCROLL
SCROLL.type property = flash.events.Event.SCROLL

Defined by the original TextField class

textInput Event  
Event Object Type: flash.events.TextEvent.TEXT_INPUT
TEXT_INPUT.type property = flash.events.TextEvent.TEXT_INPUT

Defined by the original TextField class

Examples
This example will show you how to create an instance of a TextArea class and feed it with fmlText. and make it call functions when you rollOver, rollOut or click an href link in your script.
     import flash.text.TextFieldAutoSize;
     import com.doitflash.text.TextArea;
     
     var _textArea:TextArea = new TextArea();
     _textArea.condenseWhite = true;
     _textArea.autoSize = TextFieldAutoSize.LEFT;
     _textArea.embedFonts = false;
     _textArea.border = true;
     
     _textArea.holder = this;
     _textArea.client = this; // must be where you have your 'allowed functions' saved
     _textArea.funcSecurity = true;
     _textArea.allowedFunctions(myCustomFunction, funcOnOver, funcOnOut);
     _textArea.mouseRollOverEnabled = true;
     _textArea.fmlText = "<p>This is a <a href='event:myCustomFunction();onMouseOver:funcOnOver();onMouseOut:funcOnOut()'>link</a>.</p>";
     
     this.addChild(_textArea);
     
     
     
     function myCustomFunction():void
     {
         trace("custome function");
     }
     function funcOnOver():void
     {
         trace("rollOver text = " + _textArea.rolledOverText);
         trace("rollOver url = " + _textArea.rolledOverUrl);
     }
     function funcOnOut():void
     {
         trace("rollOut");
     }
     
In this example you will see how to create different href links to call custom functions and pass different types of arguments to them.
     import flash.text.TextFieldAutoSize;
     import com.doitflash.text.TextArea;
     
     var _textArea:TextArea = new TextArea();
     _textArea.condenseWhite = true;
     _textArea.autoSize = TextFieldAutoSize.LEFT;
     _textArea.embedFonts = false;
     _textArea.border = true;
     _textArea.multiline = true;
     _textArea.wordWrap = true;
     _textArea.width = 200;
     
     _textArea.holder = this;
     _textArea.client = this; // must be where you have your 'allowed functions' saved
     _textArea.funcSecurity = true;
     _textArea.allowedFunctions(stringLink, objectLink, arrayLink, arrayObjectStringLink);
     _textArea.mouseRollOverEnabled = true;
     _textArea.fmlText = "<p>Pass String as arguments in this <a href='event:stringLink(simple string)'>link</a>.</p>";
     _textArea.fmlText += "<p>Pass Object as arguments in this <a href='event:objectLink({var1:val1,var2:val2})'>link</a>.</p>";
     _textArea.fmlText += "<p>Pass Array as arguments in this <a href='event:arrayLink([val1,val2,val3])'>link</a>.</p>";
     _textArea.fmlText += "<p>Pass mixed arguments in this <a href='event:arrayObjectStringLink(string,{var1:val1},[val1,val2])'>link</a>.</p>";
     
     this.addChild(_textArea);
     
     
     
     function stringLink($value:String):void
     {
         trace("custome function");
     }
     
     function objectLink($obj:Object):void
     {
         for (var param:String in $obj)
         {
             trace(param + " = " + $obj[param])
         }
     }
     
     function arrayLink($arr:Array):void
     {
         for (var i:int = 0; i < $arr.length; i++ )
         {
             trace(i, $arr[i]);
         }
     }
     
     function arrayObjectStringLink($str:String, $obj:Object, $arr:Array):void
     {
         trace($str);
         
         for (var param:String in $obj)
         {
             trace(param + " = " + $obj[param])
         }
         
         for (var i:int = 0; i < $arr.length; i++ )
         {
             trace(i, $arr[i]);
         }
     }
     
The following example will demonstrate how you can load custom tags available in the TagLibrary. Please refer to TagLibrary class to see the xml tag structure supported for different tags. for the sake of simplicity we use the <image> tag in this example.

This example will show you how to register listerers for lsitening to when a module is loaded. you should note that in order to interact with the loaded module inside your TextArea instance, you should use the id attribute of that module.

NOTE: If testing this example in CS*, it's probable that the output window throw the following error message Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. please make sure you have set the paths to the assets folder and the image file you're trying to load correctly and if they are ok, ignore that message! it only happens when in CS* IDE and works fine if you open the swf directly, or through a browser or even works fine with other IDEs like FlashDevelop.

     import flash.text.TextFieldAutoSize;
     import com.doitflash.text.TextArea;
     import com.doitflash.text.events.TextInLineEvent;
     
     var _textArea:TextArea = new TextArea();
     _textArea.condenseWhite = true;
     _textArea.autoSize = TextFieldAutoSize.LEFT;
     _textArea.embedFonts = false;
     _textArea.border = true;
     _textArea.multiline = true;
     _textArea.wordWrap = true;
     _textArea.width = 200;
     
     _textArea.addEventListener(TextInLineEvent.MODULE_LOADED, onModuleLoaded);
     _textArea.holder = this;
     _textArea.client = this;
     _textArea.assetsPath = "assets/"; // 
     _textArea.mouseRollOverEnabled = true;
     _textArea.fmlText = "load an image with the \"image\" tag: <image src='image.gif' width='140' height='140' align='left' id='id1' />";
     
     this.addChild(_textArea);
     
     function onModuleLoaded(e:TextInLineEvent):void
     {
         trace(e.param.module); // reference to the loaded swf file of the module
         trace(e.param.id); // outputs the id attribute of the loaded module
     }
     
Copyright 2011, DoItFlash. All rights reserved. This work is subject to the terms and software agreements in http://www.doitflash.com/.