ActionScript 2.0 :: For Loop To Display Arrays
Jun 7, 2011
I'm trying to display strings stored in arrays with a for loop, i could just write out each array like:[code]but it only displays the last one, is there a way to display it from 1-10, or 1-any number?
View 4 Replies
Similar Posts:
Nov 29, 2011
basically I need a loop within a loop to compare two different arrays in my actionscript3 lottery game. I have attempted the loop but I cannot seem to get it to work ...
[Code]....
So basically within this code check_win is a button. Once the button is clicked it runs the loop. It is meant to take an instance of matches which contains 6 properties and loop until index is greater than matches. According to my output this is happening but the second loop doesn't appear to do anything.
View 1 Replies
Aug 25, 2010
How do i word a for loop to make it loop through multiple arrays?I want 1 for loop to loop through multiple arrays in order to move/alter objects.I want to keep the arrays separate.
ActionScript Code:
characters = new Array();
characters[0] = male;
[code]........
View 3 Replies
Apr 18, 2009
I need to assing two dimensional with random numbers so i just try to do it in a loop, but it can not be done the way I show You below.[code]trying to run that code I just get an error...
View 1 Replies
Feb 9, 2012
I have a problem to use each code in for loop. I create 2 Circles in my stage with addChild code. And I gave them function ( mc.x += 2; ) and the time they get to the end of stage I gave the function ( mc.x -= 2; ) but my problem is when one of the circles get to end and wants to move to the right the other circle move with him to the right. and I think the each code in for loop helps me. but I don't Know how to use it in my actions.
my code is:
ActionScript Code:
var mc1:Circle = new Circle();
var mc2:Circle = new Circle();
[code]....
What should I change in this code to use each for loop..?
View 9 Replies
Jun 15, 2005
creating multiple arrays in a for loop? This doesn't work :
for (i=0; i<catNum; i++) {
var arr(i):Array = new Array ()
}
[Code].,...
View 7 Replies
Nov 15, 2008
Is it possible to have a for loop and create a new array for every loop
for
(i=0; i<5; i++){
myArray+i:array=new Array;
}
I know this doesen't work it just illustrates what im after.
View 6 Replies
Mar 16, 2010
I wanted to know if there's a way to add more options to a for loop regarding arrays. Say the current position in the loop is 1 (thats where my block is) then i want it to check the array if current position -1, +1,-3,+3. if any of these are null (thus, empty spot.) Because the block moves across a board i need the script to be adaptable.
View 3 Replies
May 23, 2007
I have two arrays - one for movieclip buttons and one for images. The idea is - rollover a button and it loads it's respective image. I have a loop for the button array that pretty much loads each button and creates a rollover state for it. At the moment it just traces what button the mouse is over. The problem is trying to load the correct image based on that button. The way it is now - it will only load the same image for all the buttons.
Code:
tagPosition = 0;
viciousImgs = new Array("vaI1_mc", "vaI2_mc", "vaI3_mc", "vaI4_mc", "vaI5_mc");
viciousButs = new Array("va1_mc", "va2_mc", "va3_mc", "va4_mc", "va5_mc");
vicious = new Array("vicious_mc", "uTitle_mc", "uTxt_mc", "uButs_mc", viciousImgs, viciousButs);
[code]....
View 2 Replies
May 12, 2009
Is there a way to do this somehow?
Code:
var someVariable:int = 3;
for(var i:int = 0; i< someVariable; i++){
var mainArr[i]:Array = new Array();//I get an error if I try this
[Code]....
View 6 Replies
Apr 4, 2011
How can I use arrays and some how display my objects accordingly based on my code below?
What I have here are three buttons that when clicked a new clip is added to the stage with a predefined position which means that when button1 is clicked the MovieClip will be added at the very top and when button2 is clicked the MovieClip will be added at second and when button3 is clicked the clip will be added at the very bottom, but what I would like to do is to be able to dynamically position these objects based on how many clips exist, in other words if button3 is clicked first, I want the clip to be positioned at the very top and if later button1 is clicked the clip is positioned
Accordantly (at second place). I know this may be simple, in fact I could probably use a few IF statements but I know the code would look ugly (yes, even more) and I may have add more buttons later. What I would be awesome is to some-how use arrays or something that makes more sense to hold the MovieClips and then display them accordingly.
ActionScript Code:
button1.addEventListener(MouseEvent.CLICK, addItem1, false,0,true);
button2.addEventListener(MouseEvent.CLICK, addItem2, false,0,true);
button3.addEventListener(MouseEvent.CLICK, addItem3, false,0,true);
[Code].....
View 3 Replies
Mar 1, 2011
So im recreating my ear training program with more effective coding so i can add on to it. original i did.
//88 C8
var mp3Req88:URLRequest = new URLRequest("88.mp3");
var mp3_88:Sound = new Sound();
mp3_88.load(mp3Req88);
I basically got 88 sound files (each note of the piano) doing this code 88 times for each sound. with mathamatical equations made my ear training program.
Is there a simpler way to import these sounds in a loop of some sort so i dont have to do this 88x for the piano and however many times for the other instruments i will be including?
thus var i have tried things along the lines of below with failure
var i:int;
for (i = 0; i < 5; i++)
{
var pianoMP3Req+i:URLRequest=new URLRequest("piano/"i+"mp3");
[Code].....
View 1 Replies
Mar 24, 2012
I hope I am clear enough. My data set is populated I have
comment:CommentVO;
comment.replies=[comment:CommentVO,comment:CommentVO,comment:CommentVO];
_comments:Array = [comment:CommentVO,comment:CommentVO,comment:CommentVO]
I've correctly populated my _comments Array and the replies array in my CommentVO Obj.
[Code]...
View 3 Replies
Jun 9, 2006
[code]In my real application, I've actually created a named array with element1 as key...so that I can address it directly by it's name.The problem is that - in my real application - the array2 element doesn't share a name in common with element1 (so I could address it by its name..as just told you,using named array) but with element5.
View 1 Replies
Mar 23, 2009
I have a array of categories, for e.g.
var categoryArray = new Array('value1', 'value2', 'value3');
I would like to loop and create new arrays from each of the values in the categoryArray I tried...
for(var i=0;i<=categoryArray.length-1;i++){
this[categoryArray[i]] = new Array();
}
value1[0] = "dsfsdf";
trace(value1[0]);
It doesn't seem to work.
View 3 Replies
Oct 26, 2009
I'm trying to declare arrays inside a for loop, then access them later as if they were declared publicly/globally. This doesn't work:
Code:
playlist = addChild(new MovieClip());
playlist.header = new Array();
for (i=0; i<3; i++) {
playlist.header[i] = playlist.addChild(new MovieClip());
or (j=0; j<6; j++) {
[Code] .....
How would I declare the arrays within the for loop, but still access them later without them becoming undefined?
View 2 Replies
Jul 6, 2004
i m doing a program which contain few text. When i click a button,'step 1' text will be view. When i second, 'step 2 ' text will be load out and 'step 1' text is still in the stage.. the method i m using is array.i put my text in an arrays.
View 9 Replies
Jul 3, 2006
i am trying to create a loop that will put a list of names from external sources into a number of Arrays .so what i did is :
Code:
for (i=0; i<4; i++) {
this["loadVarsText"+i] = new LoadVars();
this["loadVarsText"+i].onLoad = function(success) {
[code].....
and i dont understand why it is not working, and how can i fix it?
View 3 Replies
Mar 30, 2010
How do I loop through all of my children, and display each? I would like to know the best way to do this. my children and containerfive children, one plays every sec, 1,2,3, etc.
[Code]...
View 1 Replies
Sep 4, 2009
All I am trying to do is display a movieclip (just a small rectangle) and have it repeat along the x-axis, adding one to it's instance name each time. It seems to work according to the trace statements but it only displays the last movieclip.
Here is the code:
var transition:mcTransition = new mcTransition();
for(var i:int = 1; i < 10; i++){ trace(i); addChild(transition); transition.x = i * 10; transition.name = "transition_mc" + i; trace(transition.name); trace(transition.x);}
View 2 Replies
Dec 9, 2009
I know this is probably really simple but it is frustrating me. All I am trying to do is display a movieclip (just a small rectangle) and have it repeat along the x-axis, adding one to it's instance name each time. It seems to work according to the trace statements but it only displays the last movieclip.
Here is the code:
var transition:mcTransition = new mcTransition();
for(var i:int = 1; i < 10; i++){ trace(i); addChild(transition); transition.x = i * 10; transition.name = "transition_mc" + i; trace(transition.name); trace(transition.x);}
View 1 Replies
Jun 30, 2011
In a Flex project, I have an array with objects in it. I want to save this array in a cell on a mysql table along with some other basic info like title, and an id. How to echo all the rows... I'm trying to echo the contents of an array that was serialized and placed in a single cell. This array has objects in it. So, I have this code here to serialize the array, and insert it along with the other info into my DB:
function submitLogDbObj($array,$id,$title) {
$title=mysql_real_escape_string($title);
return mysql_query("INSERT INTO logs (text,id,title) VALUES ('".serialize($array)."','$id','$title')");
}
Then for a test I'm trying to make a loop that will display the log in a way that looks like a conversation... An object in my array would look something like:
[1]
icon = ""
msg = "this is a test"
name = "Them: "
systemMsg = 0
[Code] .....
View 3 Replies
Aug 13, 2010
Currently I am trying to load 5 different swfs in order. Everytime a button is selected I want to move to the next swf. And once I reach 5 the next image should be 1 (again - loop). I started with a code like this on frame 1 in "scene 1":
Code:
gotoAndPlay(50);
Stage.align = "T";
Stage.scaleMode = "noScale";
_root.j = 1;
where "_root.j = 1" ----- "1" is the first swf loaded. But it was stuck on 1.
My newbie skills figured this out so to avoid zero, but it's random. And things repeat too closely.
Code:
gotoAndPlay(50);
Stage.align = "T";
Stage.scaleMode = "noScale";
_root.j = random(4)+1;
My Question: What can "_root.j" equal so that 1,2,3,4,5 cycles? I have to work within these parameters cause this template is deep.
View 1 Replies
Jan 31, 2009
i have 2 arrays (both with same length), and i need to display them like this:[code]array1 has codes and array2 says if they are enable or disable in html i would solve the problem easily with a for loop and a table, but in flash i really don't know how to do this.and, there is any way to change the color of the word 'disable' to red and 'enable' to green?
View 3 Replies
Oct 26, 2009
I need a solution to this simple problem.
var myName:String = "Pink Floyd Sound";
var i:Number;
myFig = new Array();[CODE]....
I want to display the string text 10 times using the for loop. I did this, and all I get is undefined.
View 2 Replies
Sep 5, 2009
Would it be possible (Without being extremely inefficient) to loop through a display object and reset their children's ChildIndex based on their y value?
View 1 Replies
Aug 16, 2010
just trace out the data within the "item tag" below. I can trace out the three at the top but can't get into the items. Having it nested like this is giving me problems. I would really like it to loop through the items and display each in a single text field.
[Code]...
View 4 Replies
Jan 21, 2011
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.
View 1 Replies
Aug 26, 2009
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.
View 5 Replies
Mar 31, 2011
I have a MovieClip called item with the same linkage set and my first task is to display 10 of these items on the stage nested inside a movieclip called MainItem. I have dragged MainItem to the stage and have the following for loop:
[Code]....
View 5 Replies