Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact |

CustomTextArea

Package:
Class:
Inheritance:
biz.flashscript.components.textarea
public class CustomTextArea
AbstractClass extends Sprite
The CustomTextArea class is used for the CustomTextArea component. To create an instance of the CustomTextArea use the constructor new CustomTextArea(). The difference to the UI TextArea component is that styling of the skins is easier and a css stylesheet can be applied. This is version 1.1 of the component removing several bugs.
Public Properties
Property Defined By
cssUrl : String
This is the url for a css stylesheet.
CustomTextArea
embFont : Boolean
Specifies whether to embed fonts.
CustomTextArea
myHeight : int
Sets the height of the TextField.
CustomTextArea
myTextFormat : TextFormat
Sets the TextFormat for the TextField.
CustomTextArea
myWidth : int
Sets the width of the TextField.
CustomTextArea
textValue : String
Specifies the text for the TextField.
CustomTextArea
Public Methods
Method Defined By
CustomTextArea()
Creates a new instance of the CustomTextArea component.
CustomTextArea
textAddition(tValue:String)
Will add the string specified by the parameter to the TextField.
CustomTextArea
Events
Event Defined By
All inherited events for the Sprite class.
Property Detail
cssUrl property
cssUrl:String [read-write]

This specifies the path for a css Stylesheet.

There is default value. .

.

Implementation

public function get cssUrl():String
public function set cssUrl(value:String):void

embFont property
embFont:Boolean [read-write]

Specifies whether to embed fonts. The embedded fonts have to be defined by a css stylesheet or there will be no text displayed.

The default value is false.

.

Implementation

public function get embFont():Boolean
public function set embFont(value:Boolean):void

myHeight property
myHeight:int [read-write]

This defines the height of the TextField.

There is no default value specified. The height is determined by the original size of the component instance, which is 100 pixel. The height can be changed by Actionscript or by placing a hard copy of the component on the timeline and changing its height manually.

Implementation

public function get myHeight():int
public function set myHeight(value:int):void

myTextFormat property
myTextFormat:TextFormat [read-write]

This defines a new TextFormat for the TextField.

Implementation

public function get myTextFormat():TextFormat
public function set myTextFormat(value:TextFormat):void

myWidth property
myWidth:int [read-write]

This defines the width of the TextField.

There is no default value specified. The width is determined by the original size of the component instance, which is 100 pixel. The width can be changed by Actionscript or by placing a hard copy of the component on the timeline and changing its width manually.

Implementation

public function get myWidth():int
public function set myWidth(value:int):void

textValue property
textValue:String [read-write]

This specifies the text of the TextField instance. The textValue can also be added using the textAddition(tValue:String) method.

There is no default value specified.

Implementation

public function get textValue():String
public function set textValue(value:String):void
Constructor Detail
CustomTextArea ()  Constructor
public function CustomTextArea()
Intializes a new CustomTextArea instance.
Method Detail

textAddition ()  method
public function textAddition(tValue:String)

This method will display the specified text in the TextField. This method is useful, when the text of the textArea component is manually changed by a Button event for example.

Parameters

  • tValue:String ____ Specifies the text displayed in the TextField.
Examples
Create a new fla file and name it CustomTextAreaExample.fla. Place the fla in the same folder as the biz folder. Create two instances of the CustomTextArea component and name them "textArea" and "textArea2". Set a size height smaller than the image. Then have the image ready in a folder named "icons". Change the image name appropriately. Place a button and name it "myBut". Then create an Actionscript file, name it CustomTextAreaExample.as and place this script.
package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.text.*;
	import flash.net.URLRequest;
	import flash.net.URLLoader;
	import flash.events.MouseEvent;

	public class CustomTextAreaExample extends Sprite
	{
		private var textValue1:String;

		public function CustomTextAreaExample ():void
		{
			var format:TextFormat = new TextFormat();
			format.font = "Verdana";
			format.color = 0xFF0000;
			format.size = 16;
			textArea.myTextFormat = format;
			textArea.textAddition ("This is a working text.");
			myBut.label = "Press Button";
			myBut.addEventListener (MouseEvent.CLICK,clickHandler);

			textArea2.cssUrl = "xml_files/body.css";
			var urlRequest:URLRequest = new URLRequest("xml_files/susan.xml");
			var urlLoader:URLLoader = new URLLoader();
			urlLoader.addEventListener (Event.COMPLETE, loadFinished);
			urlLoader.load (urlRequest);
		}
		private function clickHandler (e:MouseEvent):void
		{
			trace ("clicked");
			textValue1 = "<img src='icons/news.gif' vspace='0' hspace='2'/><br/>This is image 1. If the text is larger 
			the scrollbar will be activated as in this example.";
			textArea.textAddition (textValue1);
			textArea2.textAddition ("<h1>TEXTAREA 2 headline</h1><br/>",true);
			textArea2.textAddition ("The second textarea has a new text.<br/>",true);
			textArea2.textAddition ("The second textarea has a very different text.",true);
		}
		private function loadFinished (ev:Event)
		{
			var myXML:XML = new XML(ev.currentTarget.data);
			var myText:String = myXML.p.toString();
			textArea2.textAddition ("TEXTAREA 2 headline<br/>",true);
		}
	}
}