ActionScript 2.0 :: Dynamic Array Names In A For Statement?
Nov 27, 2007
I am making an XML multiple-gallery flash site for a client. The chunk of code I am having trouble with is populating the thumbmails section of the site with all the pictures in all the galleries. The image paths are brought in and stored in an array - one array for each gallery's image paths. The problem is that when I try to cycle through all the images to put them into movie clips (using a fore statement) I am having trouble dynamically addressing the arrays. More specifically, flash interprets them as strings, and does not evaluate the variables in them.
Code:
function images(i){
var temp:Number = eval("g"+i+"im.length");
for (var r:Number=1; r<=temp; r++){
[Code]....
The argument images() takes is the gallery number (from another function). I have tried using eval() and trace to see what the problem is. Basically I can make it output the correct STRINGS, but flash will not convert the variables in the strings! So in the URL (first arg) of loadMovie it is seeing something like "g2im[3]" as a string, and not evaluating it to the value at index 4 of that array.
View 2 Replies
Similar Posts:
Dec 10, 2004
I have a for statement, using an incrementing variable "a." A dynamic amount of herbs are generated, so here is the for statement.
Code:
for(a=1; a<_global.herbAmount+1; a++) {
var herbMC = _root["herb"+a];
trace(herbMC);
}
When I trace "a," it traces 1, 2, 3 or however many numbers there are up to the global herbAmount number. When I trace _root["herb"], _level0.herb pops out. When I add "a" onto _root["herb"], undefined is traced....why?
View 8 Replies
Jun 28, 2009
Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?
[Code]...
View 7 Replies
Dec 14, 2010
I was wondering if it was possible to create the name of a NEW array dynamically. I have tried the following with no success. Does anyone know if this can be done?
Actionscript Code://Tried and failed_global["newArray"+newArrayNumber] = new Array();//Tried and failed_this["newArray"+newArrayNumber] = new Array();//Tried and failednewVariable = _this["newArray"+newArrayNumber];newVariable = new Array();
View 1 Replies
May 28, 2009
This should be simple but I can't come up with or find the answer anywhere. All I want to do is create a series of Arrays with instance names generated on the fly. I then want to reference these later. I have a "for" loop with a variable "count" that I want to add to a base name of rowArray and use the result to create an Array. I would think that it would look something like this:
[Code]...
View 2 Replies
Oct 15, 2009
I've got an array (slides) that I parsed from an amfphp return that contains the following data in each array element:
slides = (chapterName, lessonName, slideName, slideText), for every slide in the course
I'm trying to get arrays out this that will look like:
chp1Array = list of Lesson names in that Chapter
chp1Less1Array = list of slide names in that Lesson
chp1Less2Array
chp2Array
chp2Less1Array
chp2Less2Array
chp2Less3Array
etc. etc.
This wouldn't be a problem in as2 but I can't get it to work in AS3 because it gives me errors when I try to create the arrays with dynamic names from within the function? How to get the dynamic number into the array name...
View 9 Replies
Jun 13, 2009
I have a function that is called from a timer event. Every time the event is called I need to create a new Array with a unique name:
Code:
var dropNumber:int = dropHead.length - 1;
var ["dropTail" + dropNumber???]:Array = new Array();
I am not sure how to dynamically change the name of an array with as3. Also, just a bonus question, is it more efficient to have a single array broken into partitioned indexes or have several arrays of data?
View 3 Replies
Jun 22, 2010
Ok, Background. I have two objects both of which im spawining in though code. We will call them bullets and wolves. They have their own .AS files which tells them everything they need to know about themselves. I figured i would do most of the hit testing on the bullet.AS file, hit testing against the wolves as there were going to be a set number of wolves but not a set number of bullets.o, I named them by running a loop and putting the linenewWolf.name = i.toString();Yes, new wolf is a declared variable, and i is the name of the variable that makes the loop run. I also have a test in it, and it works fine.
However, The hit testing is where i come into an issue. Remember, its on a seperate .AS file. The wolf maker and namer is on the main flash page.The hit testing function isif(this.hitTestObject(a)){i changed up my variable name to run a second loop. first variable name is "i" and the second variable name is "a"And for some reason i get a type error 1034, which from what i understand is an error that you get when two instance names are the same. Also, If possible, i would like to add letters to the name of the object, but im not sure if flash will let me as i belive the code would look something like this
View 1 Replies
May 1, 2003
i have an array of array names, but i'm having trouble with it being considered a string:
<BR>
onstageArray = ["_root.backstageArray", "_root.perfArray"];
<P>
[code].....
View 2 Replies
Mar 14, 2011
I've been seaching on how to get the key names of a flex Array as there is no such function in the Array class. Here is my answer that may be usueful to any of you.
View 2 Replies
Oct 21, 2010
I have an array called mclipArray with the names of movie clips stored in it as follows:
mclip0, mclip1, mclip2, mclip3....and so on until mclip99.
Later in my code I want to run a loop using "i" as a counter variable from 0 to 99 and then depending on the value of "i" add various movie clips to be inside the movie clip that corresponds to "i". For example if I want to add a movie clip called "someMovieClip" as a child of my movie clip called "mclip6" and my loop has been running and "i" is now equal to 6, how can I use "i" to reference the correct index stored in the array.
mclipArray[i].addChild(someMovieClip);
The above code doesn't work.
View 7 Replies
Nov 22, 2010
I want this to be sorted by first name only: "John Smith 18", "Charlotte Smith 59", "Chris Doe 26", "Tony Jordan 100", "Charlotte Roberts 17", "Imad Hanna 26", "Charlotte Smith 13"
I can get it sort sort alphabetically just by using .sort(), but it takes into account the last name as well.
View 4 Replies
Apr 19, 2005
I have an array that creates 7 mc clips with names.I'm trying to make each one of those peices clickable.When clicked each peice will slide over to the far left "barrier_mc" and stop.Actually not true, the one closest to the "barrier_mc" will stop at the barrier and from then on each piece will stop when it hits the one beside it (kinda like a 7 car fender-bender). This isnt the problem im trying to work through right now, although i will in the near future.
What im trying to figure out is the array that creates the mc's names them like the following "" infoBar"+i+"_mc"". What im trying to do is call that in a function so that i dont have to type in each of the 7 mc names manual I.E (infoBar0_mc) you'll see my function at the bottem in the "function pieceStop"of the pasted code.
Code:
var list:Array = ["piece1", "piece2", "piece3", "piece4", "piece5", "piece6", "piece7"];
var startingX:Number = list_mc._x;
var bottom:Number = 950;[code].....
View 2 Replies
Feb 12, 2007
ok so i have this array from which i wanna fetch names of the XML files i want to load in their XML object, so i write like this but it doesn't work.[code]
View 2 Replies
Apr 5, 2010
I have some movieclips on stage each with an instance name like this: 101, 102,103,104.. etc.When I click one of them, it's istance name is added in an array:[code]I've got a button on stage too and I want when this button is clicked to change the Y of all the selected movieclips:[code]
View 6 Replies
Jul 8, 2010
I'm trying to reduce repetition in my code by using a for loop with an attachMovie call. [code]So I have a bunch of clips in array that I want to attach, and I just want to use the name of the clip as the instance name, but it doesnt seem to work.
View 3 Replies
Apr 19, 2012
I have a bunch of buttons on stage, and i want to place all of those buttons names in an array so i can assign an event listener to them easier. What i have is:
Code:
var btnArray = new Array["btn1","btn2","btn3","etc...."];
for(var c=0; c<btnArray.length; c++)
{
btnArray[c].addEventListener(MouseEvent.MOUSE_OVER, doSomething);
}
But that isnt working.
View 2 Replies
May 27, 2010
I am trying to create a pretty simple image script for a flash website. What it does is to create a container named mc and then loads in an image into the mc from XML. It goes through the XML file like in a for each loop. But the problem I have is that every image container then gets the name mc. So then now when I try to build the function which makes it possible to press on one of the image containers to enlarge them, it only makes the last image larger since that is the last one to be created with the name mc. So how do I give every movieclip that I create a different name such as mc1, mc2 etc.[code]
View 8 Replies
Apr 14, 2009
I'm looping through an array and checking the elements to see if an element contains this text. the array is as following
[Code]...
i've narrowed down the problem to being the variable 'current'. If I replace the dynamic part to the string '_A_1' it works. That is why I entered the trace just above to see what its is checking against. I can see that they are both the same, but flash thinks otherwise.
View 2 Replies
Mar 24, 2012
In Flash, I created a grid of 400 buttons with instance names c0 through c399.[code]...
View 2 Replies
Feb 5, 2010
I have just started actionscript after a long break, I am creating a crossword and each box is an 'Input Text' field. Since there are a lot of text fields, I do not want to have to create variables for each text box,I wanted to do something like this:
ActionScript Code:
var inputs:Array = new Array( "_1a", "_1b", "_1c" .. );
for( var i:int = 0; i < inputs.length; i++ ) {
[code]....
View 3 Replies
Jun 30, 2010
How do you pass instance names into arrays? I've got a bunch of movieClips of states.
They all have instance names.. alabama, arkansas, delaware, florida, georiga, etc..
I am trying to send them all to an array because I need to be able to disable the movieClips all at once and I don't want to call each one separately. I setup an array and a "for" loop, and it properly gets each value in the array:
ActionScript Code:
states = new Array(alabama, arkansas, delware, florida, georgia);
stateslength = states.length;
[Code].....
View 9 Replies
May 14, 2011
I want to know "is it possible to get the files names into an array from a specific path".
The flow go like this..
When i open the swf file --> browse the specific folder -> read the file names into an array --> show the file names.
View 1 Replies
Jul 8, 2011
I've continued with it and have hit another hurdle. When I run the loop to load in the XML images, inside the same loop I add instances of a "thumb" movieclip onto the stage. It's just a little graphic that I want to use as thumbnail buttons. So for example, if the XML loads in 3 images, 3 instances of the "thumb" mc also load onto the stage. I currently give then unique names in the loop but that name gets overwritten each time the loop runs. How can I record each name of the instance? I'm guessing an array but how do you populate an array with a loop?
Then, I'm hoping if those names are recorded in an array, then I can reference the different thumb instances (so they can do different things with the images) and also use removeChild on them when I close the gallery and load in the next gallery. Here is my code so far,
[Code]....
View 6 Replies
Jun 24, 2009
Why I can't set properties to instance names with Array
Code: Select all// instance names:
// a1_mc, a2_mc
var allElements = new Array("a1_mc","a2_mc");
allElements.x = 250;
alllements.y = 250;
View 3 Replies
Mar 13, 2009
[code]I've tried some various things (including "this"), but basically, I need to loop through data held in arrays to create several dynamically named functions on the the fly.
View 1 Replies
Sep 15, 2011
I am writing my quest .as files for my RPG that I am making. At the present moment I am having issues with certain commands and how best to accomplish them. This pertains to my conversation system that I have in place. Currently, the conversations are stored as an array, with each index in the array representing a different "page" of the conversation. Now for my quests, at the end of each conversation (the last index in the array), I want a certain function to occur (receiving the quest, updating the quest, completing the quest). So my thought is to have a separate array with the same number of elements as the conversation array, and when the conversation text is updated to reflect the next page, it also will access the function array with that given index, and therefore only on the last page of the conversation will the function be executed.
Code:
var a:Array = [func0, func1, func2];
function func0():void{
trace(0);[code].....
Now my question is this, when is the code actually executed? When it is placed within the array, or when it is accessed with the for statement?
View 3 Replies
Feb 18, 2005
I want to parse the image names in the following XML into an array:
<?xml version="1.0" encoding="UTF-8" ?>
- <ride>
- <gallery>
<image>1_gallery_1.jpg</image>
[Code]....
What would the variable name be to get to the start of the image names?
IE: this.firstChild.childNodes.childNodes[0].firstChild.nodeValue
I'm having a really hard time figuring this out.
View 1 Replies
May 18, 2009
I have an array that houses the names of six movieclips. I randomly select three of them. I am trying to get my randomly chosen movieClips to do what I want them to do. I have tried the following code to get the first to fade in:
[Code]...
But it does not work. The trace comes back with the full movie clip name ex: mcTom, but even though that value comes up in the trace, the AS doesn't see it as a movie clip. Any thoughts on how I can correct this?
View 4 Replies
Jul 3, 2009
I am trying to simplify things by using dynamic MovieClip names. I have three MovieClips on the stage.
1) mcPage1
2) mcPage2a
3) mcPage2b
But my code isn't working. I'm guessing the "this" part is what is messing it up. Thinking that the computer doesn't know which MC is "this". It traces fine outside the function, but inside the function it traces undefined.[code]
View 2 Replies