Skip to content


Combining Arrays with the Array.Concat Method

The Actionscript Document Class:

package
{
	import flash.display.Sprite;
	import fl.controls.TextArea;
	import fl.controls.ScrollPolicy;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;

	public class ArrayConcat extends Sprite
	{
		private var output:TextArea;
		private var ArrOne:Array;
		private var ArrTwo:Array;
		private var ConcatArrays:Array;

		public function ArrayConcat()
		{
			init()
		}

		private function init():void
		{
			// display our output field
			Output();

			// set up the arrays
			ArrOne = new Array(1, 2, 3);
			ArrTwo = new Array(4, 5, 6);
			ConcatArrays = ArrOne.concat(ArrTwo);

			// display the output
			msg ( "OUTPUT" );
			msg ( "-----------------------------------" );
			msg ( "ArrOne: " + ArrOne );
			msg ( "ArrTwo: " + ArrTwo );
			msg ( "Concatenation....." );
			msg ( "ConcatArrays: " + ConcatArrays );
			msg ( "-----------------------------------" );
		}

		// UI elements

		public function Output():void
		{
			// Small Black Text Formatting
			var smallBlackFormat:TextFormat = new TextFormat();
			smallBlackFormat.font = "Arial";
			smallBlackFormat.color = 0x000000;
            smallBlackFormat.size = 10;
            smallBlackFormat.underline = false;

        	// output TextField
			output = new TextArea();
           	output.verticalScrollPolicy = ScrollPolicy.ON;
           	output.condenseWhite = true;
           	output.setSize(stage.stageWidth, stage.stageHeight);
           	output.move(0,0);
           	addChild(output);
        }

		public function msg(m:String):void
		{
			output.appendText (m + "\n");
		}

	}
}

Posted in Actionscript 3, Arrays, manewc.com.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.