ActionScript 2.0 :: Looping Non-array Variables With Eval()
Sep 3, 2003
I want to do a for loop that grabs values from different variables. This function works nicely without the eval() statement (using the commented line below it) but not with it.
function saveData ()
{
saveUrl = "savedata.php?";
for (count=1; count<=numberOfVariables; count++)
I have a variable call php_variable that loads from the php. It echos all the necessary variables. I have 2 array, Tel_start and Tel_area. The messages.text is just a text field I use to test if things are loading properly.
[Code]...
It display the correct string. But when I use Tel_start[0] like above, I got undefined. So here, the actual quesetion, what's the proper way of storing those variables and displaying it?
I'm not really good at figuring out how to do some things in Actionscript and I'm confused about looping throught functions with thins like eval. Here's my code :
[Code]...
I'm trying to loop to dynamically create functions. I have 5 boutons and I don't want to duplicate 5 times the same code. This code works but I don't seem to be able to use the same eval trick on the variable "blnBtn05". Anyone knows why and how can I be make it work?
Why doesn't AS2 interpret these variable as it steps through? Everything works if I write it out longhand and do not use a loop, but if I try to condense things by using an array, variables such as _root.myTargets[i]._x are not interpreted properly.
Code:
myTargets = new Array('shoot','shoot2'); for (var i:Number=0; i<myTargets.length; i++) { if ((_root._xmouse > (_root.myTargets[i]._x - 30)) and (_root._xmouse < (_root.myTargets[i]._x + 50)) and
I'm having problems in setting three variables using a for loop and then passing these variables to my function. I think it's something to do with the set function I'm using, because my colorFadeTo function claims it's being passed an undefined variable.
Code: for (var i=0; i<circles.length; i++) { var current = circles[i];
I have a clip containing 8 MCs, named id1, id2 etc, each of which contain a dynamic text field with the variable thisNo. I want to run a loop that inserts each digit from a randomly generated number into each of these MCsPatID is the random number, IDLength is it's character length.
I have a response coming in from a server that contains a ton of strings that I need to eval to have them replace arrays already set as globals. So program fetches response, evals string into an array, and then we do stuff with the array. I've played around with little tests and can't get it working.
ActionScript Code: var superArray= new Array('3','4'); var testArray="superArray=['1','2']"; function testEval() { eval(testArray); trace(superArray); [Code] .....
stuck on a bit of code, trying to transition a program over from JS to AS2 flashlite 3.1.So here's the deal, I have a response coming in from a server that contains a ton of strings that I need to eval to have them replace arrays already set as globals. so program fetches response, evals string into an array, and then we do stuff with the array.I've played around with little tests and can't get it working. This is a dumbed down version of what I need to happen.[code]
Having a hard time trying to resolve this issue, done a bit a of digging but can't find what i'm after. I'm pretty new to AS3 but know that Eval() has gone and been replaced with [] syntax. However, i'm trying to access a dynamic path to a clip and it seems that the array syntax will not allow more than one variable in a path.
I'm using LoadVars (results_lv below) to load variables from an ASP page, returned as follows: option1=4&option2=5&option3=32&option4=... etc. etc.
There are a different number of "options" returned each time, depending on the query sent to the script. I have access to the number of options ahead of time, but still don't know how to loop through them...
So... How on earth do I loop through these variables?!? Basically I'd be thrilled to be able to do this:
How can I make a bunch of variables from a for loop. for example for (var i=0; i<total; i++) {var bunch(i);}. that i make a bunch of variables named bunch1, bunch2, bunch3. I keep getting errors. I program and use so many different languages that I dont know if that can be done with AS3. my only other alternative i can think of is to create some sort of event dispatcher object array. but I dont know how to get them all to send events to one listener with there index number.
I have a list of strings that I add to an array, then attempt to set those values in a for-loop using data that I read in. The array gets updated, but the values the array contains do not. I also have an array of buttons that I update this same way that works great, but strings don't seem to work the same way. I have tried moving the string array to give it full scope, and still nothing...
public class test extends Sprite { // Declare a list of strings protected var title0:String = undefined;
I have an XML document that loading into Flash. I have a dynamic text box on the stage that I am writing the XML to. My problem is, I have 6 group names that I am pulling from my XML file and I want to write each one of them to the text box and add a line break to the end. This is my code:
var group= this.firstChild.firstChild.childNodes; for (var i=2; i<group.length; i++){ divBox['divInfoLinks'].htmlText =
[Code].....
When I trace [i] it lists all 6 names, however my text box only shows the last name in the array.
There is a bird, and you control its upwards movement with a key. It has thrust, gravity, it works fine. The problem is I have a bunch of icicles that come at the bird that he is supposed to avoid. I tried this first with math random to use as an x coordinate and than move across the screen, but the icicles had the same x-coordinates sometimes. I tried does not equal(!=) but that doesn't work. I made an array and each number that came out of the array I assigned a different variable. This works fine. I put this variable into the x-coordinate such as mc.x=((n)*60)+480. I did this for five different icicles. All their differnt variables have a different value, and I put them into the same function for each individual video clip, but they still don't go to the right coordinate. Here is the test code just for the initial coordinate of each icicle before it moves...////////////////////////////Quote:
var temp:Array = new Array() for (var i:int=0;i<8;i++) { temp.push(i);
I am attempting to build an array of arrays that will with the following syntax. My output is definitely not what I am trying to achieve. Here is my code:
[Code]...
My output is coming out as 6 references to "Set3". There is obviously something wrong with my for loops, but I can't figure it out.
I tried implementing a Counter and every time flash goes to another variable in array, i would increment that Counter and i would see if Counter == Array.length.[code]...
I am trying to download 3 files from a website by defining an array and looping through the urlloader commands I am using urlloader so that the user doesn't have to confirm each download, my code is:
I have two arrays. One is used for button names and the other is used for the links for the buttons. The buttons are generated dynamically with attachMovie and the names are also modified via AS. My problem comes in at looping through the links array and applying them to the buttons.[code]
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.
I've got no idea how to phrase this, but is there a simple/efficient way to do something like this that doesn't feel hacky:?
[Code]...
I realize I can just trade the index number in the brackets for a function that returns the corrected index (after it works through the end of beginning of the loop as needed), but what's the best or most efficient way to do this? The damn 0 as the first position in an array really confuses me sometimes when trying to work these things out.
I am trying to loop my function through my array values continuously. I'm only able to get it to loop through one array value as intended. The long term goal here is the create a grid of movie clips that continuously change colors in random order (from preselected values). I'm new to actionscript and I have been racking my brain trying to figure this out. I'm unsure of how to send the function to all items in the array, and loop them all continuously, yet with random color patterns for each.
I would like to repeat a block of code within a function in Flex, which is the best way to do this, I would like to do this without making a new function?
The code currently is:
Code: for each (var rawPhoto:Object in event.data) { logger.info("Photos.getPhotos: Photo[{0}] downloaded", rawPhoto.pid);
Hey guys, thanks in advance for any help, I'd be stuck all the time without these forums.
I have a custom class(Ball) and a .FLA. Ignore the custom class, it works fine, having a problem within my main FLA.
I'm getting repeated "Error #1009: Cannot access a property or method of a null object reference. at Environment_fla::MainTimeline/hitTest()".
I understand that this error means I'm asking it to reference something that's no longer there. I just can't figure out why I'm getting it, and how better to hitTest many objects in an array.
My game involves creating a bunch of balls that will fall into buckets. I need to keep track of how many touched the buckets, how many fell off the screen, and remove each accordingly.
Thanks again, very much appreciated.
Here is the code from my main FLA
[as]var ballTimer:Timer = new Timer(200); var changeTimer:Timer = new Timer(50000);
//Environment variables var gravity:int = 1.5; var friction:Number = .85; var color:int = 2;
//score variables var YellowScore:int = 0; var BlackScore:int = 0;
var tBall:Ball = new Ball(new Point(mouseX, mouseY), new Point(Math.random() + Math.random()*5 + Math.random()*8), gravity, friction); var ballArray:Array = new Array();
function throwBall(e:TimerEvent):void {
var tBall:Ball = new Ball(new Point(mouseX, mouseY), new Point(Math.random() + Math.random()*5 + Math.random()*8), gravity, friction);
Here is my xml structure: <question> <q1> Who coined the term "Clinical Psychology"? </q1> <answer> Lightner Witmer </answer> <option1> Stanley Hall </option1> <option2> Lightner Witmer </option2> <option3> Henry P. David </option3> </question>
I can loop through fine and pick out the questions and answers, then throw them into separate arrays. The problem I'm having is looping and pulling the options into a multidimensional array like such: var one:Array = new Array( 3 ); one[0] = ["Stanley Hall", "Lightner Witmer", "Henry P. David"]; one[1] = ["Stanley Hall", "Lightner Witmer", "Henry P. David"]; one[2] = ["Stanley Hall", "Lightner Witmer", "Henry P. David"];
I am preloading multiple mp3's dynamically using a looping array and it is working very well. However, I would like to display the percetage of the last mp3 loaded by the array.Does anyone know how I would modify the code to do this:
Code: var my_array:Array = new Array(); my_array[0] = "Audio/audio_1.mp3";