TextToArrayToString

Package:
Class:
Inheritance:
biz.flashscript.text
public class TextToArrayToString
N/A
The TextToArrayToString class is a text class and will convert an array into a string with slashes separating individual array members. Use the constructor TextToArrayToString.getInstance().
Public Methods
Method Defined By
TextToArrayToString()
Creates a new instance of the TextToArrayToString class.
TextToArrayToString
makeString((stringData:String, addLetter:String = ""):String
Returns the array as a string with slashes.
TextToArrayToString
Constructor Detail
TextToArrayToString()  Constructor
Intializes a new TextToArrayToString instance.
Method Detail

makeString ():String  method
public function makeString(stringData:String, addLetter:String = ""):String

This method will return a string with slashes separating the array members.

Parameters

  • stringData:String ____ Specifies the array to convert.
  • addLetter:String = "" ____ Specifies a string/letter/space to add after each array member. Default is none.
Examples
Create a new fla file and name it Texttoarraytostring.fla. Place the fla in the same folder as the biz folder. Place a dynamic textfield on the timeline and name it myText. Then create an Actionscript file, name it Texttoarraytostring.as and place this script.
package 
{
	import flash.display.Sprite;
	import biz.flashscript.text.TextToArrayToString;
	import flash.text.TextField;

	public class Texttoarraytostring extends Sprite
	{
		public var myText:TextField;
		
		public function Texttoarraytostring ():void
		{
			var myArray:Array = new Array("a","d","c","3","5","v");
			myText.appendText ("Print Array:      "+myArray+"\n");
			myText.appendText ("Print split array:     "+TextToArrayToString.makeString(myArray)+"\n");
			myText.appendText ("Print and add space:      "+TextToArrayToString.makeString(myArray, " ")+"\n");
			var newString:String = TextToArrayToString.makeString(myArray, " and ");
			newString = newString.substr(0, newString.length - 5)+".";
			myText.appendText ("Print and add ' and ':     "+TextToArrayToString.makeString(myArray, " and ")+"\n");
			myText.appendText ("Convert to a sentence:    "+newString);
		}
	}
}