how can i set an array by using a loop.. the array is contains by a data that i read from database.. so the length of carry depend of the length of data in my database..
i try to use
for (var i:int = 0; i < xxx; i++) {
products = [p[i]];
}
i never read data from database in as3.. so if i want to use the data in database for this loop,what should i do?
ActionScript Code: var answerArray:Array = ["3", "2", "5", "3", "2"]; //these are the correct answers var answeredArray:Array = ["3", "1", "1", "3", "2"]; //this is an example of what the user
I have this flash movie I've been working on for awhile. I've received in these forums. I have my file set to load an array of swfs. Now, though, I'm wondering how to keep it from looping. At the end of the last swf, I want the movie to go to the last swf and then just stop. Here is my code:
I have this map I'm creating in Flash. You click on a state, then you can click on an icon to view a tooltip/popup of some information. What I was trying to do was instead of creating new functions and event listeners for every different icon is to use a for loop...but it's not going so well.[code]...
I've a container file which loads an array of SWFs. The code is as follows:
var request:URLRequest; var loader:Loader= new Loader(); stage.addChild(loader); var myMovies:Array=["../flash/movie1.swf","../flash/movie2.swf", "../flash/movie3.swf"]; var movieNum:int=0; var mcExternal:MovieClip; [Code] .....
This works fine - the array is loaded and plays through once... What changes are needed to get it to loop through the array.
I'm having to make an array that has each value increase by a 10, like 10, 20, 30, etc. is there an easier way to put in those values without adding them 'manually'?
and I have another question that is related. For this same project, on the stage there will be a text box and the user will put in a number--how can that value be run through the array? like say I input the number 500, how does it find it in the array? is there a passed id, a listener and a broadcaster?
var myData = new Array(); myData["name"] = "John"; myData["Age"] = 35;
What is the syntax to loop through and get the key and value? I have tried for each and for in but they just give me the value of "John" or "35", how can I get the key e.g. "Name" and "Age"?
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
Old code:
ActionScript Code: mc_array = new Array(); for(i=0;i<5;i++){
Consider an array with x number of elements (of type Object) where some of the elements might be undefined.I use a for-each loop to access all the elements of the array that is not undefined (since it simply skips the undefined elements).But I also want the index of that particular element.The only option I can see is to use indexOf(). But it feels a bit like looking for water on the other side of the river so to speak.
When looping through long arrays each frame, is there a change indexOf() might slow it down? or does the for-each loop somehow know what index it's dealing with?
I am quite new to AS3 and I am having trouble adapting my knowledge of Java to this new language i am trying to make a simple grid in which i could work on each individual square seperately(changing their colour for example). To do so, I created a 2D array,hoping it would allow me to work with some kind of coordinates system. I initialised the array using while loops and for some reason, this does not let me access the array outside the loops.[code]The two last lines are causing the problem, instead of turning the last square red, they return the following error: TypeError: Error #1010: A term is undefined and has no properties.However, when placed inside the loop, there is no problem and the whole grid turns red.
I like to use array.length in my for loop to keep my code cleaner to read. Is there any huge downside to this? For example will it speed up things greatly if i store the length in a var one time?
Is it possible to to loop contents in an Array? Something like this? for (var s:Number = 1; s<21; s++) { var me = ["tfNm"+(s)]; var mcB = ["_root.gmb_mc."+me+".tf"]; var mcC = ["_root.gmbb_mc."+me+".tf"]; //trace (mcB) var mcA:Array = [mcB, mcC, _root.F5]; ///// }
Below I have an array that works but it is far too long and I am thinking there is a far easier way to generate the same result using a loop but I just can't get my head around it at the moment. The array is as follows:
var CardDeck = new Array(); CardDeck[0] = new C1(); CardDeck[1] = new C2(); CardDeck[2] = new C3(); CardDeck[3] = new C4(); CardDeck[4] = new C5(); CardDeck[5] = new C6();
There's 3 boxes I'm indexing through with a timer. They disappear in sequence. How do I make them reappear?
boxes disappear in sequence 1-3
var pink:Array = ["","boxInstance1","boxInstance2","boxInstance3"]; var timer:Timer = new Timer(555); timer.addEventListener(TimerEvent.TIMER, onTimer);
[Code]....
I'm not to particular about the sequence they disappear and appear, but it need to keep going in a loop.
is there anything changed in actionscript in flashbuilder 4? i'm new to as3.... why is following for loop not assigning value to array ?i tried in various ways, but could not get it
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
I've got the following script that loops an array of movieclips at random positions in and out of the stage using Tweener. My problem is that the loop uses all the movieclips (WELCOME00, WELCOME01, etc.) at once. What I'd like is for the loop to only use one of the movieclips, chosen at random, for the loop instead of all of the movieclips listed in the array at one time.
Code: import caurina.transitions.*; var mcArray:Array = [WELCOME00, WELCOME01, WELCOME02, WELCOME03]; var init:Boolean = true;
I need to loop an array that also play the swf to the end beffor it goes to the next array. How whould i do that? if anyone could link me to a page where i can find out or tell me how i did it would be great.
i have this but this dosent work as i wannt:
ActionScript Code: function onCompletePreloading():void { contentContainer.addChild(_swfClipsArr[0]);
[Code]....
insted of having the "addEventListener(MouseEvent.CLICK, setContent);" i need something that counts the current frame and the end frame of that swf is that possible?
I have been following tutorials but they don't seem to cover exactly what I'm doing.I have an associative array of values called definitionsArray which I use as references to instantiate classes in a run time shared library.I instantiate and push the object into a new array. The problem is when I try to access or do anything basically with that new array.As they are objects they don't seem to like being in a display list for example.
ActionScript Code: var definitionsArray:Array; var bubblesArray:Array;
What I've got is a menu that loads images as buttons. It will only display menu items that are within a certain group (i.e. if themenuitem.node Value == groupid[q] then it will display that menu item. Each of the menu items has a unique number (Itemnumber[n]). I have a loop that goes through and displays the menu items that are within a certain group. I am currently able to also find out the unique number of each of the menu items where themenuitem.nodeValue == groupid[q], but what I want to do with these numbers, is place them all into an array as it loops through.So, say for example, it finds an item in the loop. It tells me this item is number 4 (if I tell it to trace(Itemnumber[n]) within the loop). Then, it finds another item in the loop, and it tells me this item number is 6. I want to be able to add items to an array as it loops through, so I'll have an array at the end like this: (4, 6).Currently my ActionScript looks like the following. Never mind if there are variables that are not defined in there -- they have been defined in other parts of my movie.[code]As you can see, I've made an attept at achieving this by trying numarray[numarraylength] = n; -- but all this does is send me an array, then overwrite it next time it loops (so I get an array like (4, 4), then one like (6, 6). I've added comments in the code to further explain what I'm trying to do.