Share on Google+Share on Google+

Indexed Vector Array in Action Script 3.0

Ads
In this example, you can see how to insert value in the indexed array class instance with different data types.

Insert value in Indexed Array class instance example:-

In this example, you can see how to insert value in the indexed array class instance with different data types.

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.Text;

public function init():void{

var arr:Array = new Array();

arr[0] = "a";

arr[1] = 5;

arr[2] = 5.8;

arr[3] = true;

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

var text:Text = new Text();

text.text = arr[i];

myVBox.addElement(text);

}

}

]]>

</fx:Script>

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

<s:VGroup id="myVBox">

<mx:Text text="Array values" fontWeight="bold"/>

</s:VGroup>

</s:Panel>

</s:Application>

  In this example we have create a Array class instance. You use the array access ([]) operator to specify the index position of the element you wish to access or insert in the array. After that we have insert values that have different data types with the help of access operator and after that we have access that array for retrieve these values.

Output:-

Download this code

Advertisements

Posted on: June 8, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.