ActionScript 3.0 :: How To Put Arrays Inside Another One
Nov 9, 2011
How can I put array inside another array? E.g.
[AS]
var TU: Array = new Array (a1.TUO, a1.TUI);
var TD: Array = new Array (a1.TDO, a1.TDI);
var TR: Array = new Array (a1.TRO, a1.TRI);
var TL: Array = new Array (a1.TLO, a1.TLI);
[/ AS]
I want to put TU TD TR and TL as an item inside another array as "main array for all those arrays" Like this
[AS]
var MAIN_ARRAY: Array = new Array (TU, TD, TR, TL);
[/ AS]
How can I call or deal with an item for example "a1.TLO" form the main array "MAIN_ARRAY" after we put the arrays inside the main array? I want to know how can i put arrays inside another array "as main array", and how can I deal with the items which are in the arrays which are inside the main array?
I have created an array, which contains all of my menu items. All I want is, when the pointer rolls over one menu item MC, the others disappear.
var titles:Array = new Array("contact_mc","food_mc","links_mc","test_mc", "look_mc"); contact_mc.onRollOver = function(){ titles.pop("contact_mc"); titles._alpha = 0; <<< this is what I want, BUT how do I write the correct Syntax? }
And does flash know - the items in the array are MC's ... or just strings! ?
In the example below i have two arrays: warmColours and coolColours. I put them in an array called allColours. So far so good.I make a copy of allColours (allColoursClone). I try to edit one of the values of its cloned warmColours sub-array. And here's the problem: changing warmColours in the clone also changes the original.I wan't to make an independent copy of it without any connection to the original.[code]
I have a private class variable that is an array. I have the getters and setters like I would for any other variable. When I push something on to the array from outside of the class using the instancename.arrayname.push() it pushes it onto all of the arrays of all instances of that object like it is a static variable or something.
I've created a game of top trumps. 64 cards and randomized and the 30 are selected. The 30 are then split between 2 arrays, one called PlayerCards and the other called AICards. Only problem is that the cards don't play in any order and often the same card is played 2-3 times in a row. I want to number the random cards in each the PlayersCards and AIsCards 0-14. How do I number the 15 cards in both the PlayerCards and AICards arrays?
I have an Arrays that contains the names of MovieClips:
Code: var MyMCs:Array = ["A","B","C","D","E"];
The actual MovieClips names are "MC_A", "MC_B", etc..., I use this method so I reuse the same Array for multiple tasks, I simply add what ever it's needed to the name to match the task at hand. On this case I add "MC_".
Then I have multiple Arrays, with the same names of the values of MyMCs. The values of each these Arrays are the names of buttons that are inside the movieclips of MyMCs:
Code: var A:Array = ["RR","TT"]; var B:Array = ["YY","UU"]; etc...
My problem is that i want it to be done dynamically, using the Arrays values in a loop to add Listeners to the all buttons. The loop system is not a problem for me... my real problem is in the dynamic attribution itself. Here is what I have:
Code: //'i' and 'j' have previously been created for(i=0; i<MyMCs.length; i++){ for(j=0; j<this[MyMCs[i]].length; j++){
[Code]....
I know that this is correct since I tried them separately and I can trace the proper values.
I know that my problem is in the "this" since I get an error message stating: 1084: Syntax error: expecting identifier before this.
I suppose it should state something else... I tryed with "root", "parent", "child", "MovieClip"... with no luck...
I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:
var slideDataArray:Array = new Array(); var slideShowDataArray:Array = new Array(); slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........
I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.
I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.
I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:
var ar1:Array = [1,2,3,4,5,6,7,8,9]; var ar2:Array = ['a','b','c','d','e','f','g','h']; function merge(...multi):Array[code].....
Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.
A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:
ActionScript Code: for(var i:int=0;i<vQuantity;i++){ ranArray.push( new Object() );
I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.
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:
AllBrigades (array of Brigades) Brigade (object) BrigadeUnits (array within Brigade object) Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
I have done this same thing in ActionScript 3, but am not familiar with ActionScript 2, which I am forced to use for this project. I am loading products into a SWF via XML and attempting to add a click event to each dynamically-created movieclip. Simply tracing the text from a node in XML will do for now. I'd like to assign a property called "desc" or "description" to each movieclip and have it trace that property's value when clicked. Here is the relevant portion of my code as it stands:
ActionScript Code: var iXML:XML = new XML(); iXML.ignoreWhite = true;
I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.
var xml:XML; var xmlReq:URLRequest = new URLRequest("xml.xml"); var xmlLoader:URLLoader = new URLLoader();
I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.
var xml:XML; var xmlReq:URLRequest = new URLRequest("xml.xml"); var xmlLoader:URLLoader = new URLLoader();
[Code]....
It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.
I have a flash code where i am loading an AS 2 SWF inside AS 3. The thing is if i put the AS 2 SWF on same domain its working fine but if i put AS 2 SWF on different domain it loads the SWF properly but the "stop()" written inside the AS 2 frame doesnt work... and it keeps on playing all the frames continuously...
I have a flash code where i am loading an AS 2 SWF inside AS 3. The thing is if i put the AS 2 SWF on same domain its working fine but if i put AS 2 SWF on different domain it loads the SWF properly but the "stop()" written inside the AS 2 frame doesnt work... and it keeps on playing all the frames continuously...
Here is the loading code..
var context:LoaderContext = new LoaderContext(); if(Security.sandboxType == Security.REMOTE){ context.securityDomain = SecurityDomain.currentDomain }; var objLoader:Loader = new Loader();var mRequest:URLRequest = new URLRequest("SomeURL.swf");objLoader.contentLoaderInfo.addEventListener(Event .COMPLETE, onSWFLoadComplete);objLoader.load(mRequest, context);
is there any way I can link a button inside a MC on frame1 to a frame inside another MC that is located on another frame.Ive got 2 frames in total. On the first frame Ive got an Mc and inside this one Ive got a button that needs to be linked to frame number 50 which is inside a MC located on frame number 2.
if i have A:Array [1,4,7] and B:Array [5,3,9], how do i turn it into: C:Array [1,4,7,5,3,9]?I've checked the Array class in help ofcourse, but concat(rest ...) can only take in paramaters directly, not an array. is this possible or do i have to do it manually?
i want to do a quiz with 10 questions .i want to save my 10 questions in an arrays.The question will show randomly and once the question has been asked the question will not repeat.
This part works fine, but what doesn't work is the script I try to add to the movieclips. If i add EA[t]._x += 10, then only the lastly created enemy moves. How do i make it so that all of the enemies move?
I've searched everywhere and can't seem to find a clear explanation or basic example. How do you compare the elements of 2 arrays to see if there is a match?
The scenario is to create a lotto game that matches 6 user inputted numbers with 7 randomly generated numbers. The 7th number is a special case (eg bonus ball) WOULD LIKE TO SHOW A KIND HEARTED FALSH GENIUS ALL OF THE SCRIPT IF POSS! (its not tooo long) This code works, but it just outputs the default message: There seems to be a problem with my arrays not comparing? Part of the code is: (prioir to this the user inputs numbers, they are copied to text areas beginning with O, on a button press) On a second button press randomly generated number appear to a timer. //compareResult checks how many numbers match between the two sets of numbers to determine winnings.
I'm just fooling around making an inventory system and I was wondering if there is a way to work out the next available index in an array without pushing the item into the array.So for instance
var array:Array = new Array(); array[0] = new Object(); array[1] = new Object();