| Package | com.doitflash.text |
| Class | public class TextArea |
| Inheritance | TextArea TF 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:
Call functions in your project and pass different types of arguments like arrays, objects or simple strings to them: <a href="event:funcOnClick(val1,val2,[arr1,arr2,arr3],{var1:value1,var2:value2,var3:value3})"> http://www.doitflash.com/</a>
Call rollover or rollout functions for a href links.
<a href="event:funcOnClick();onMouseOver:funcOnOver();onMouseOut:funcOnOut()">
http://www.doitflash.com/</a>
Create new tags to load different modules inside your texts. check out the class TagLibrary to see the list
of available tags. just as a quick example, you can load an image (which supports animated .gif files also), like this:
<image src="image.gif" width="140" height="140" align="left" id="imgId" />
NOTE: Following attributes must always be set in all tags, width, height, align and id
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | assetsPath : String | TF | |
![]() | base : Object | TF | |
![]() | client : 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 | |
![]() | data : Object | TF | |
![]() | flashVars : 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 | ||
![]() | holder : Object | TF | |
![]() | id : 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 | ||
![]() | serverPath : String | TF | |
![]() | xml : XML | TF | |
| Method | Defined By | ||
|---|---|---|---|
TextArea()
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 | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Defined by the original TextField class | TextArea | |||
| Defined by the original TextField class | TextArea | |||
| dispatches when a text-in-line module loads into the TextArea. | TextArea | |||
| Defined by the original TextField class | TextArea | |||
| Defined by the original TextField class | TextArea | |||
| fmlText | property |
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.
public function get fmlText():String public function set fmlText(value:String):void| funcSecurity | property |
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.
public function get funcSecurity():Boolean public function set funcSecurity(value:Boolean):voidSee also
| mouseRollOverEnabled | property |
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.
public function get mouseRollOverEnabled():Boolean public function set mouseRollOverEnabled(value:Boolean):void| rolledOverText | property |
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.
public function get rolledOverText():StringSee also
| rolledOverUrl | property |
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.
public function get rolledOverUrl():StringSee also
| 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.
| 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):ObjectBy 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.
|
Object — the text-in-line module.
|
| getModuleLoader | () | method |
public function getModuleLoader($id:String):LoaderBy 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.
|
Loader — Loader object of the module.
|
| change | Event |
flash.events.Event.CHANGEflash.events.Event.CHANGEDefined by the original TextField class
| link | Event |
flash.events.TextEvent.LINKflash.events.TextEvent.LINKDefined by the original TextField class
| onModuleLoaded | Event |
com.doitflash.text.events.TextInLineEventcom.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 |
flash.events.Event.SCROLLflash.events.Event.SCROLLDefined by the original TextField class
| textInput | Event |
flash.events.TextEvent.TEXT_INPUTflash.events.TextEvent.TEXT_INPUTDefined by the original TextField class
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");
}
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]);
}
}
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
}