Home Tutorial Flex Flex4 Components Indexed Array in AS3

 
 

Share on Google+Share on Google+
Indexed Array in AS3
Posted on: June 8, 2010 at 12:00 AM
Advertisement
If user want to store multiple value in a single data structure then it can be used Array for this process.

Indexed Array in Action Script3:-

If user want to store multiple value in a single data structure then it can be used Array for this process. Indexed array is a type of it. Indexed array provides you to store a collection of one or more then one value. It is used unsigned integer value for access each value of the indexed array. The first index of the indexed array is always number 0 and increase by 1 for each value added in the array. The indexed arrays used two classes : the Array class and the Vector class.

Array Class example:-

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="init();">

<fx:Script>

<![CDATA[

import mx.controls.Alert;

import mx.controls.Text;

public function init():void{

var cities:Array = new Array("Kanpur", "Delhi", "Aligarh", "Jaipur", "Mumbai");

for(var i:uint = 0; i<cities.length; i++){

var text:Text = new Text();

text.text = cities[i];

myVBox.addElement(text);

}

}

]]>

</fx:Script>

<s:Panel width="160" height="170" title="Array Class example" backgroundColor="0xEEFFEE">

<s:VGroup id="myVBox">

</s:VGroup>

</s:Panel>

</s:Application>

Array class instance can hold  different types of data type. In this example, we have used Array class instance that hold string type cities name after that we have accesses it.

Output:-

Download this code

Indexed Vector Array in Action Script 3.0
In this example, you can see how to insert value in the indexed array class instance with different data types.
 
Advertisement

Related Tags for Indexed Array in AS3:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 8, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com