ActionScript 3.0 :: Put Variables In An Array?

Sep 1, 2009

Is this possible? To put variables in an array? Say if I wanted to declare:

ActionScript Code:
var twentythreeX = 0;
var unihiphopX = -320;
var unimetalX = -760;

then use these to make a button go to these coordinates?

[Code]....

View 8 Replies


Similar Posts:


ActionScript 3.0 :: Array Of Variables - Make A Bunch Of Variables From A For Loop

Feb 21, 2009

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.

View 5 Replies

Actionscript 3 :: Changes To Array Of String Variables Doesn't Update The Variables Themselves

Jul 30, 2010

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;

[Code]....

View 1 Replies

ActionScript 3.0 :: Array Variables, Variables Not Working Correctly?

Jul 11, 2011

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);

[code]......

View 1 Replies

ActionScript 2.0 :: Setting Array Values To Variables In Another Array

Dec 11, 2007

I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated. A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.[code]How would you do this so that var1, var2... are updated properly according to the values found in array2?And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?

View 6 Replies

Flash8 :: Put Variables In An Array?

May 31, 2009

Is it possible to put variables in an array?

For example:

Code:
var positions:Array = new Array(Stage.width / 2, Stage.height / 2);

When the above code is executed, the values "Stage.width / 2" and "Stage.height / 2" are replaced with the number values and the array becomes, for example [500, 400].And when I call the array positions[0], instead of getting the value of the Stage.width / 2 (considering the stage has been resized), I get the static value of 500.What can I do to get the value of Stage.width / 2 ?

View 1 Replies

Using Variables To Target An Array?

Jun 1, 2011

Its easier explained if I just write down the code:

function loadMc(frame:Number){
aNum = "array"+frame;
array1 = ["mcname", "identifier", "200"];

[code].....

View 1 Replies

Looping Through Array Of Variables?

Jan 27, 2010

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

[Code]....

View 1 Replies

ActionScript 3.0 :: Using Variables In An Array?

Sep 1, 2009

I think I am getting pretty close here but can anyone direct me in the right direction to be able to return the values in the array in a sequential order?

Code:

var twentythreeX:Number = 0;
var unihiphopX:Number = -320;
var unimetalX:Number = -760;

[Code]....

This is for a simple slide show just when the next button is pressed it will tween to those coordinates.

View 5 Replies

Pass Variables From A Php File Into An Array?

Mar 20, 2007

I have successfully created a php file that reads and echoes the contents of a directory in the string [code]...

View 4 Replies

ActionScript 2.0 :: Add Array Variables Instead Of Concatenate

May 26, 2010

I have this code to push "Variable1" in to MyArray:
ActionScript Code:
_root.MyArray.push(Variable1);
Note:
"Variable1" is a number stored as a string.
When "Variable1" changes, the code above is called upon to add the new "Variable1" value in to MyArray. Then I have this code which is called upon to find the sum of all the values within "MyArray":

ActionScript Code:
for (i=0; i<=_root.MyArray.length-1; i++) {
_root.MyArray_Total = _root.MyArray_Total + MyArray[i];
}

My problem is that rather than adding the values contained within MyArray (as if they were numbers), the values are being concatenated instead.

Example:
If MyArray values were 1, 2, 3
I want the MyArray_Total to = 5
But instead... MyArray_Total = 123

I tried making a new variable named "Variable1_num", declaring it as a number, making it equal to "Variable1", and then pushing "Variable1_num" in to "MyArray"... but that didnt seem to work either.

View 1 Replies

ActionScript 2.0 :: Use Variables With Array Assignments?

Jul 13, 2011

I searched this and other forums and could not seem to find an answer for this

i am attemting to define a variable and use that variable to assign array items to a text string[code]...

View 1 Replies

ActionScript 3.0 :: Variables Inside An Array?

Aug 9, 2011

I am doing my first simple game using Flash CS5 and Actionscript 3.0. In this game the player would be able to create a new quiz where it would create an array and add sets of questions and answers to that array. I have been looking on how to do this or anything like it and it doesn't seem to be possible (at least in this way).

View 9 Replies

ActionScript 2.0 :: Filling Array With Variables?

Sep 29, 2004

I'm interested to fill a simple array with variable names, NOT with strings! , because I need it for catching the data from asp file.I tried something like that but it doesn't work

for(i=0; i < 9; i++)
{
Variables_array[i] = Variable + i;

[code].....

View 3 Replies

ActionScript 2.0 :: Multiple Variables + Array?

Feb 21, 2006

i'm trying to trace this out - but i don't believe i have the right syntax:

trace (levelNum + "Questions" + [questionNum[currentQuestionNum]].correctAnswer);

i can trace out 'levelNum' and it traces out fine. i can trace out 'questionNum[currentQuestionNum]' and it traces out fine.basically without any variables my object array would look like this:

lvl(1 or 2)Questions[(a # here)].correctAnswer.

But my trace is not working and i'm not sure how to group that all together.

View 1 Replies

ActionScript 2.0 :: Array Method - How To Effect Variables

Apr 10, 2009

I understand the Array Method:
arrayname = new Array();
arrayname [0] = "Text"
arrayame [1] = " Text2"

And have it randomly pick one via a clicked button or what have you, but how do I have these effect variables? We have randomly selected from one in the array, how do I make it so once it selects one of those, it effects one variable, and if it goes to another one effecting another variable + - or what have you, without using if statements?

View 2 Replies

ActionScript 2.0 :: CS3 - Array Loop To Change Variables?

Sep 4, 2010

The plan is to set up variables to react to a flashvars value like this:

[Code]...

There would be many mainVars (over 100, actually) and this setup isn't working.

View 1 Replies

ActionScript 1/2 :: Array Loop To Change Variables?

Sep 4, 2010

The plan is to set up variables to react to a flashvars value like this:[code=html]<param name="flashvars" value="mainVars=1" />[/code]

[Code]...

There would be many mainVars (over 100, actually) and this setup isn't working.

View 2 Replies

ActionScript 1/2 :: Many Variables Or One Array - Empty And Full?

Jun 29, 2011

Basically, there are 24 movieclips with 2 states, empty and full. Their instance names are from space0 to space23. When each movieclip are in the first state, empty what I am "planning" on doing is setting a specific variable for that movieclip called var space0empty:Boolean = true; and when it is in the second state make it false. I would have to make 24 variable for each movieclip. Is there a simpler way to do this with Arrays, also, could you please explain any code given on arrays or at least tell me how to use arrays as the equilivant for what I said with variables.

View 2 Replies

Xml :: Assign The Loaded Txt File's Array To Variables?

Nov 21, 2011

I use following flash actionscript code, got from online, to load the "Loading.txt" file:

var myTextLoader:URLLoader = new URLLoader();
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {

[code].....

View 1 Replies

ActionScript 3.0 :: Put Bunch Of Urlencoded Variables Into An Array?

Jan 16, 2009

I got a tiny problem here. I want to get a bunch of words from a database and then put them in an array in Flash. The array and database works, but the getting-the-words-in-it does not. Here's what I got[code]...

As you can see I got a counter, and a bunch of words. Now I would like to put those words in that array, by means of push(e.target.data.word%), in a for loop ran by the counter. Pretty easy, but I can't come up with a good idea to format word[i]. Then I can just use it as an index.

View 9 Replies

ActionScript 2.0 :: Accessing Many Array Variables In A For Loop?

Apr 2, 2010

how can I access my different array variables in a for loop?what i need to do is for every increment in my for loop i want to change my var array name so that i don't need to use if else condition.

Code:
var ship_array:Array = new Array("spaceship1", "spaceship2", "spaceship3", "spaceship4", "spaceship5", "spaceship6", "spaceship7", "spaceship8", "spaceship9", "spaceship10",

[code].....

View 0 Replies

ActionScript 2.0 :: Array Loop To Change Variables?

Sep 4, 2010

The plan is to set up variables to react to a flashvars value like this:

Code:
<param name="flashvars" value="mainVars=1" />

Code:
var videoArray:Array;
var videoTitle:String;
var videoFile:String;

[Code]....

There would be many mainVars (over 100, actually) and this setup isn't working.

View 0 Replies

ActionScript 2.0 :: Combine Variables To Form Array Name?

Jan 14, 2011

I'm trying to get this code to work dynamically:

ActionScript Code:
var imageArray:Array = String(imageArray0).split(",");
filePre.preload(imageArray);

I have a variable, _global.buildingNumber that I want to show up after imageArray so Flash loads the desired array.

This doesn't work:

ActionScript Code:
var imageArray:Array = String(imageArray+_global.buildingNumber).split(",");
filePre.preload(imageArray);

View 0 Replies

ActionScript 3.0 :: Using A For Loop / Array To Produce Variables?

Apr 8, 2011

This must be simple but I am unsure of the syntax for the variables and the text fields. I have to produce 200 variable names and use the variables to populate text fields. I would like to use a for loop and possibly an array.Here's what I'm trying to avoid:

ActionScript Code:
var weekDay1Text = evt.target.data.weekDay1Text;
var weekDay2Text = evt.target.data.weekDay2Text;

[code].....

View 2 Replies

ActionScript 3.0 :: Comparing Array Variables And Combine?

Aug 7, 2011

I'm trying to compare two array variables and combine if they do. This is what I have in mind: (it's inside a "for")

Code:
var people:String;
if (arr[i + 1][0]==arr[i][0]){
people = arr[i + 1][6]+", "+arr[i][6];

[code]....

The "i + 1" obviously do not work.

View 9 Replies

ActionScript 2.0 :: Array Values To Individual Variables?

Jun 13, 2006

I am trying to set variables from an array. I want my variables to be named Pic1, Pic2 etc. (according to how many values are in the array).This is code from the "parsing external array data" tutorial**

files = new Array();
lv = new LoadVars();
lv.onLoad = function() {[code].....

View 3 Replies

ActionScript 2.0 :: Using An Array To Create Multiple Variables?

Aug 23, 2006

If I have multiple variables of the same type, can I create an array and loop to create them or do I need to create them individually.

For instance,

var ajArray:Array = new Array(mc1, mc2, mc3, mc4, mc5, mc6, mc7, mc8, mc9, mc10, mc11, mc12, mc13);
for (var i:number = 0; i<ajArray.length; i++){
var [ajArray[i]]:MovieClip;
}

[code]....

View 2 Replies

ActionScript 2.0 :: Passing Array Variables By Value Not Reference

Dec 11, 2006

It took me hours to figure our why this was returning the wrong value - when assigning one array to another it passes by reference not Value. I need a way to force it to pass by values. e.g. copy the existing array and have the second array reference it, so i am free to modify the first array without changing the values of the second.[code]From the example above You see that in Actionscript when assigning one variable to another it does it my reference not value. So when you chage the value of one array it changes the value of the other automatically.I need to have the "test2" variable reference the "test1" array only by value so if modify "test1" the values of "test2" won't be modified.

View 7 Replies

ActionScript 2.0 :: Splitting An Array Into Multiple Variables?

Aug 8, 2007

i know how to use arrays in a flash file but i'm not sure if i can split it into multiple from an input text box:

Code:
stop();
getcode = [_root.colorskin, _root.coloreyes, _root.colorwing, _root.eyes, _root.mouth];

[code].....

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved