Arrays are an important structure in any programming language. Arrays are designed to allow the programmer to hold multiple pieces of data in a single structure. In this tutorial Mark, demonstrates the basics of arrays using Actionscript and Flash Builder. Mark creates two different arrays and populates them with data. Then he demonstrates several array methods that allow you to add to the array, delete from the array, and manipulate the array in several other ways.
If you are using Actionscript with Flash Professional, Flash Builder or Flex, you will find this tutorial useful.
This “How To Actionscript” series is designed for the developer who wants to learn different Actionscript techniques quickly and easily.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <?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" minWidth="400" minHeight="500" creationComplete="init()"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ function init() { //Formal var myFamily:Array = new Array("Brett", "Kerry", "Joan", "Rick", "Kevin", "Conner", "Colleen", "Carol"); var languages:Array = ["C++", "Objective C", "Actionscript", "Java" , "PHP" , "Assembly"]; //txtResult.text = myFamily.toString(); //txtResult.text = myFamily[3]; languages[(languages.length+1)] = "C#.net"; languages.push("Visual Basic"); var returnedElement = languages.pop(); for(var x=0; x < languages.length; x++) { txtResult.text += languages[x] + "\n"; } txtResult.text += "Returned Element: " + returnedElement; } ]]> </fx:Script> <s:TextArea x="18" y="10" id="txtResult"/> </s:Application> |
Tags: Actionscript, arrays, Flash Builder, Flash Professional, Flex, tutorial, Video


