ArrayConvert

Package:
Class:
Inheritance:
biz.flashscript.utils
public class ArrayConvert
EventDispatcher implements IEventDispatcher
The ArrayConvert class loads text files and extracts variables from the file, which can then be used in the Flash movie. Use the constructor new ArrayConvert() to create an instance of the class and add parameters as desired.
Public Properties
Property Defined By
newArray : Array
An array containing all variables from the text file.
ArrayConvert
Public Methods
Method Defined By
ArrayConvert(textFile:String)
Creates a new instance of the ArrayConvert class.
ArrayConvert
splitString(myString:String)
Function converts strings separated by coma to an array (for instance from MYSQL).
ArrayConvert
Events
Event Defined By

arrayComplete

This event is dispatched when the textfile has been loaded and the variables been extracted.

ArrayConvert
All inherited events for the EventDispatcher class. N/A
Property Detail
newArray property
newArray:Array [read-write]

Sets and returns an array.

There is no default value.

Implementation

public function get newArray():Array
public function set newArray(value:Array):void
Constructor Detail
ArrayConvert ()  Constructor
public function ArrayConvert(textFile:String)
Intializes a new ArrayConvert instance with the specified parameters.

Parameters

  • textFile:String ____ Specifies the URL for a text file.
Method Detail
splitString ():void  method
public function splitString(myString:String):void

Parameters

  • myString:String ____ The string to be converted.
Event Detail

arrayComplete event

Event Object Type: biz.flashscript.utils.ArrayConvert
Event.type property = biz.flashscript.components.utils.ArrayConvert.ARRAY_COMPLETE

Dispatched when the file was loaded and the variables been extracted.

Examples

Create a new fla file and name it ArrayConverter.fla. Place the fla in the same folder as the biz folder. Add a TextField and name it myText. In a folder named "text_files" have a file named "textexample.txt". Then create an Actionscript file, name it ArrayConverter.as and place this script.

package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import biz.flashscript.utils.ArrayConvert;
	
	public class ArrayConverter extends Sprite
	{
		private var var1:Array;
		public function ArrayConverter ():void
		{
			var ac:ArrayConvert = new ArrayConvert("xml_files/varexample.txt");
			ac.addEventListener (ArrayConvert.ARRAY_COMPLETE, compHandler);
			but.label = "Values";
			but.addEventListener (MouseEvent.CLICK,butHandler);
			myText.appendText ("Original text:\naValue=http://flashscript.biz/&bValue=100&cValue=400&xValue=1000&yValue=300");

			/*******Split array at , important for array strings from mysql ********
			import biz.flashscript.utils.ArrayConvert;
			var var1:Array;
			var ac:ArrayConvert = new ArrayConvert();
			ac.addEventListener (ArrayConvert.ARRAY_COMPLETE, compHandler);
			function compHandler (e:Event):void
			{
			var1 = e.currentTarget.newArray;
			trace(var1[1]);
			}
			ac.splitString("(xvxcvxv|111|333|bcbcb),(sdgffdg|444|666|vnvnvn)");
			
			*************************************************************************/

		}
		private function compHandler (e:Event):void
		{
			var1 = e.currentTarget.newArray;
		}
		private function butHandler (e:MouseEvent):void
		{
			for (var i=0; i< var1.length; i++)
			{
				myText.appendText (var1[i].varName+"="+var1[i].varId+"\n");
			}
		}
	}
}			

The following Textfile (varexample.txt) is used in this example:


aValue=700&bValue=100&cValue=400&xValue=1000&yValue=300