ActionScript 3.0 :: Create A Multidimensional Array
Sep 17, 2009
I don't know why i am having problems in creating a multidimensional array (an array similar to jagged array in C language or Java) Is it possible to create an array like this in actionsript when used for Flex application??? I tried many methods like creating a simple array and adding other arrays to that or using loops etc. I don't want to add or push the whole array but something like adding one by one variable to a matrix like the one we do in C.
I't trying to create a multidimensional array of the following kind:
let's say we have a list of cities: Rome, Paris, London and a list of neighborhoods for each(i.e: rn1,rn2,...for Rome) How can I create one array that holds all that information like:
var travel = new Array() //and the travel array hold information like: Rome(rn1,rn2,rn3),Paris(pn1,pn2),London(ln1,ln2,ln 3,ln4)
so later I could access travel[0] = Rome, travel[1] = Paris and...
I have an array of movie clips (representing band members) which have various properties, among them them a property which tells where the band member went to after they left their current band. For those who formed a new group, I want to create an array. Within that array, I want to group all the ones that left for the same group into secondary arrays. So, if you had five band members and 2 of them left for group X and 3 left for group Y. What's the best way to do this? This is, roughly, my code:
[Code]...
Alternatively I suppose if I could do without a multidimensional array and just loop through all the members and say - for those members whose group is the same, perform this function, with the name of that same group passed as the parameter for the function. I guess the trouble I'm having is identifying who's the same.
I'm trying to create a multidimensional array that will act as a sort of Archive.
I have 3 different values that are assigned to a single-dimensional array. This array, called currentarray, is very dynamic and changes often. But now I want to create a whole new array while saving the information from the first array, and then I want to be able to switch in between both arrays, loading them up, changing them, saving the information into the Archive array.
So basically, the Archive array must eventually look something like this:
Since I want to shorten the code as much as possible, I made it so that Item3 in the archivearray is the position of that group of items. In English, that means that the Archive array would be like this:
I need to create a multidimensional array with a certain number of rows/columns from variables that store the number of rows/columns. For example say I have:
var r:int = 5; var c:int = 10;
I want a multidimensional array that has 5 rows and 10 columns, every space within the array filled with the value 0.
I am working on an interactive quiz type game using arrays and multidimensional arrays.
I am trying to make a dynamic textfield say "the current question" + "Sorry, the correct answer is..." + "the second answer in the first string of answers in the array".
I think I am pretty close, but there is an error in the syntax.
Here is the line of code where I try to do this:
questionHolder.question.text=(String (cat4Questions[0]) + "Sorry, the correct answer is "+ String (cat4Answers[0,2]));
I am getting this error:
VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.
I'm trying to make my portfolio XML-driven. What I'm trying to do is similiar to a photogallery. The difference is that I want "sub pictures" to every item in the gallery. Example: If I click on a project name in the portfolio an image should appear. Then I want to be able to browse between different images within that project. When I click on a another project a different set of pictures will be loaded.My XML file looks as exemplified below. What I'm having troubles figuring out how to do is getting the array right.I want to access the data something like this:
imageArray[0].path[1] would return "http://www.pic.com/picA1.jpg" imageArray[0].title returns "Title A"
I fail to parse the XML into an multidimensional array like this..
<images><item title="Title A"><pic path="http://www.pic.com/picA1.jpg"> <desc>First A picture</desc> </pic>[code].....
/////////////////////////////////////////////////////////////////////////// first off, for those who don't know, a normal array is a set of data contained in a variable, created like so: var myArr:Array = new Array("data1","data2","data3");
[code]...
(because it starts counting from 0, not one) A multidimensional array is just an array of arrays.created like so:
var myArr:Array = new Array(new Array(1,2,3),new Array(4,5,6));
and called like so:
myArr[0][1] which gives: 2 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
I have a set of 24 movieclips, which I'd like put into a multidimensional array containing 8 arrays, each containing 3 movieclips.
Code: Select allfunction addArrayDimensions() {//takes the clips array on root, and makes it an 8x3 multidimensional for (i=0; i<_root.clips.length/3; i++) {//while i<8... //assign the first three items of clips[] to a new array, and put it at the end of clips[]
[code]...
Right now, it's taking the clips array (which we'll pretend contains this data: [1,2,3,4,5,6.....])and then runs through the function, and then returns it exactly as it was before. (1,2,3,4,5,6....)How can I take an array, and make it into a multidimensional array?
I'm having some trouble with multidimensional arrays and was hoping someone could enlighten me. I am feeding in some data of projects from xml. The XML looks like this:
I have two two-dimensional arrays, and this line of code:
openListParents[compWith] = openList[olID];
Does it work? Yes. However, openListParents[compWith] becomes openList[olID], but I want openListParents[compWith] to be the value of openList[olID]. This is what I get when I press CTRL+ALT+V:
[Code].....
This is because openList might change, and I want the value of that openListParents in the array to be the value of the openList at the time when the code is run.
Here everything is alright, but I would like to do more than just trace the results. I would like to store the results in an object or an array and access it from other functions.
how to store XML data if I want to use it from other functions?
I need to get a values from php.. Its all be multi-dimensional array. How can I get the value from external php. I'm using below script for my previous works Code: var imagevarlist:LoadVars = new LoadVars(); imagevarlist.load("My_php.php"); imagevarlist.onLoad = function(ok) { if (ok) { var my_Arr:Array = this.External_Arr }} But its possible if I convert array to string in php. But Now I need to get Array only without string....
I'm creating the action script for a VRC/LRC Program [URL] The program is made up of a 5x5 matrix of input text boxes which is limited to only one character which can be either one or zero. The rows and columns will be XORed.The last column and the last row will show the results. The results will depend if the user wants and even or an odd parity.. I have trouble in XORing the textboxes.
var fitb:Array = new Array("question1","question2",[["answer1","t1"],["answer2","t2"],["answer3","t3"],["answer1","t4"]]);
It's for a quiz program. Question1 is the first part of the sentence, the answers words that are shuffled and question2 is the last part. So basically they have to align parts of a sentence in the correct order.
Everything is groovy, but I can't figure out how to check if the words are in the correct order. The current [2][0][1] position is my test for embedding the answers, but when it's shuffled it seems to ruin everything.[code]...
I'm pushing my comfort level with a multi-dimensional array. I' first created this array with brackets, but realized it should have been with parentheses, but I still get an error with the following attempt. The error reads, "1084: Syntax error: expecting identifier before rightparen"This error points to the very end of my statode]ement ");" My error is probably pretty obvious, but I can't see it.[c
So i need to search through a multidimensional array.. here is an example of what the user will see when searching the array
First name: Last name: grade:
now what i wana do is make it so the user can search through the multi/array with the first name to find the last name and grade that goes along with it... here is my failed attempt.
ActionScript Code: var dataArray = new Array(new Array(), new Array(), new Array()); var tempArray = new Array(); var eMode = null;
I have an array of objects (the first member of each object is a string which records the object's name) The other members of the objects contain various numerical information. I need to sort each category of information and display the names next to their related information in correct numerical order:
ie. AName 4235 AnotherOne 3962 OneMore 1576
Can anyone suggest some code which would do this? I checked out .sort and .onSort, built in methods of array but I can't get my head round it.There are thirteen objects in my array. The fourth element (population) needs to be sorted.
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query. I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class. The hierarchy I want to create is as follows:
when I do this my "year_cb" displays >> nissan[0][1] or nissan[1][1] depending on if you choose altima or maxima.So I've gotten it to do that much but now I need it to display the corresponding year for the part in the array i.e. plug in "1984" (nissan[0][1]) and populate the combobox through 2005 (nissan[0][2]).when I use this code:
I have my xml coming in just fine and I need to put it into an array now..I need it to basically end up like one of these:
Code: var contentInfo:Array = [{title:"Select a Ringtone", keyID:"", keyName:"", fileID:""}, {title:"Living Together", keyID:"17117", keyName:"circa.ringtones.livingtogether", fileID:"1769_w_a18cwob6.mp3"}, {title:"The Greatest Lie", keyID:"17119", keyName:"circa.ringtones.thegreatestlie", fileID:"2026_w_i2hdaw10.mp3"}, {title:"The Difference Between Medicine and Poison is the Dose", keyID:"17120", keyName:"circa.ringtones.thedifferencebet", fileID:"2025_w_yskkb1oc.mp3"}];
so you can see their are 4 variables I need to push into one slot.
I would like to know how to organize a multidimensional array.Below is the current state of the array. Three rows, and a different number of columns for each.
How can I refer to the length of a array in a multidimensional array. I'm trying to get it so that the var galleryLength would equal the amount of values in each array inside the multidimensional array.
Code: var galleries:Array = new Array( new Array("1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg","8.jpg"), new Array("1a.jpg","2a.jpg","3a.jpg"), new Array("1b.jpg","2b.jpg","3b.png"), new Array("1c.jpg","2c.jpg","3c.jpg") ); var galleryLength = galleries[currentGalleryID].length; //This value is increased to switch between the different arrays inside var galleries var currentGalleryID:int=0;