TextLoader

Package:
Class:
Inheritance:
biz.flashscript.utils
public class TextLoader
N/A
The TextLoader class allows to load text and XML files. Use the constructor new TextLoader() to create an instance of the class and add parameters as desired.
Public Properties
Property Defined By
varData : Boolean
Specifies if URLVariables are used to convert to the proper dstsformat.
ArrayConvert
Public Methods
Method Defined By
TextLoader(textFile:String, loadParse:Function, myCache:Boolean=false, aNum:Object=null, bStr:Object=null, cBool:Object=null) TextLoader
Property Detail
varData property
varData:Boolean [read-write]

If true the data format "URLLoaderDataFormat.VARIABLES" is used (see example).

There is no default value.

Implementation

public function get varData():Boolean
public function set varData(value:Boolean):void
Constructor Detail
TextLoader ()  Constructor
public function TextLoader(textFile:String, loadParse:Function, myCache:Boolean=false, aNum:Object=null, bStr:Object=null, cBool:Object=null)
Intializes a new TextLoader instance with the specified parameters.

Parameters

  • textFile:String ____ Specifies the URL for a text- or XML file.
  • loadParse:Function ____ The listener function, when the loading is completed.
  • myCache:Boolean=null ____ If true will add something to the url of the textfiel to prevent caching.
  • aNum:Object=null ____ Optional: A parameter to transfer to the listener function.
  • bStr:Object=null ____ Optional: A parameter to transfer to the listener function.
  • cBool:Object=null ____ Optional: A parameter to transfer to the listener function.
Examples
Create a new fla file and name it Textloader.fla. Place the fla in the same folder as the biz folder. Add a TextField and name it myText. In the same folder have a file named "textexample.txt" with text containing html tags. Then create an Actionscript file, name it Textloader.as and place this script.
package 
{
	import flash.display.Sprite;
	import biz.flashscript.utils.TextLoader;
	import flash.events.*;
	import fl.controls.Button;
	import flash.text.TextField;

	public class Textloader extends Sprite
	{
		public var myBut:Button;
		public var myText:TextField;
		private var myData:Object;
		private var mt:TextLoader;
		
		public function Textloader ():void
		{
			myText.appendText("Textexample: aValue=http://flashscript.biz/&bValue=100&cValue=400&xValue=1000&yValue=300\n");
			myBut.label = "Load";
			myBut.addEventListener(MouseEvent.CLICK, clickHandler);
		}
		private function completeHandler (e:Event,a:String,b:Number,c:Boolean):void
		{
			myData = e.currentTarget.data;
			myText.appendText("myData.aValue: "+myData.aValue+"\n");
			myText.appendText ("a: "+a+"  "+"\nb: "+b+"  "+"\nc: "+c+"\n");
			myText.appendText ("e.currentTarget.data.aValue: " +e.currentTarget.data.aValue+"\n");
		}
		private function clickHandler (e:Event):void
		{
			var mt:TextLoader = new TextLoader();
			mt.varData = true;
			mt.initText ("xml_files/varexample.txt",completeHandler);
		}
	}
}