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


Similar Posts:


Actionscript 3 :: Concatenate Variables For Flash?

Apr 6, 2011

I'm trying to make a function which ideally you tell it to go to the next level and it sorts everything out to transition to the next level for you. Currently I use this to get from level 1 to 2...

[Code]....

Also I need to make it so it checks if levelText == whatever on press of the Enter key, as well as the mouse click on GoButton.

View 2 Replies

ActionScript 2.0 :: Multiple Variables (concatenate With Delimiter)?

Mar 30, 2011

The course contain ten chapters that all have to report that when a user completed them. When they all are, the status is set
to "completed" for the course. First off the theory behind it:

1. I just completed a chapter.

2. Load a string with then numbers "0,0,0,0,0,0,0,0,0,0", one for each chapter. All 0's, no chapter is completed, all 1's, all chapters are completed, you get the picture.

3. Add a 1 for, lets say chapter 5, would look like this "0,0,0,0,1,0,0,0,0,0".

4. Check if the course is complete, like this: "1,1,1,1,1,1,1,1,1,1", or not.

5. If complete, set status to "complete", if not, set to "incomplete".

In practice:

import flash.external,*;
String(ExternalInterface.call("LMSGetValue, "cmi.suspend_data, TheCourseStatus"));
String(ExternalInterface.call("LMSSetValue, //..add the number "1" to

[code]....

So, after this rant. How do I,

1. Get the string.

2. Add the course number/value to the string

3. Then update the string, and..

4. ..set the appropriate status.

I found out that "I need to concatenate them together with a delimiter so I can separate the string on re-entry", but I don't know how to do that.

View 0 Replies

ActionScript 2.0 :: Concatenate Variables Onto Movieclip Names?

Jun 29, 2008

var c = mainSubThumbs.SubThumbsHolder[materialType].subthumb_mc[id] what i have obviously doesnt work. materialType and id are my variables that I want to be added onto these mc instances..

View 9 Replies

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

AS3 :: IDE - How To Concatenate Variable Names

Nov 24, 2007

How do I concatenate variable names in AS3?Something like this:

for(var i:int=0 ; i<5 ; i++) {
var "myVar"+i:Array = new Array();
}

View 5 Replies

ActionScript 3.0 :: Get Text To Concatenate Properly?

Nov 25, 2008

When I use the code below the "!" never appears in the output text field. I tried removing nameInput.text and then the "!" will appear. But with nameInput.text in the code, any string I try to add after it does not appear.

View 3 Replies

ActionScript 1/2 :: Preventing Concatenate Using '+' Operator

May 27, 2009

How can I prevent concatenating when using the addition operator? totalCost_txt.text = (firstCost_txt.text + secondCost_txt.text)I can replace the "+" with any other operator and it works. (huh?)

View 3 Replies

ActionScript 3.0 :: Concatenate Dynamic Variable?

Dec 23, 2009

I'm starting out with AS3 and migrating some old code. I have several dynamic variables in AS2 but they are using _root which isnt available in AS3.How would I go about switching the following variable to AS3? I have at least a dozen different variables similar to this one.

Code:
for (i = 0; i < (k-1); i++) {
pivot = _root["AI"+i][i][i]; // existing AS2 code

[code]......

View 3 Replies

ActionScript 2.0 :: Concatenate A Name And Variable Number?

Nov 20, 2007

I'm trying to concatenate a name and variable number. Then trace it, so answer3 should output from my loaded xml data "water". Instead all I can get to trace is the word "answer3". If I type "answer3" in the trace I get the variable im looking for. If I type [this.getCorrectAnswerNumber()] in the trace I get number 3. How do I go about concatinating the word answer and a dynamic number.

Heres my code...

Code:
trace("answer"+[this.getCorrectAnswerNumber()]);

View 7 Replies

Actionscript 3 :: Concatenate Arrays When Using Different Image Files?

Dec 6, 2011

It is possible to reference an array inside of an image file name, here's the scenario.

I have a list of images that only differ by the number at the end of the name (for example. orangeimg1.jpg, appleimg2.jpg, strawberryim3.jpg, etc. Is it possible when referencing the image that I could somehow reference the array in the file name rather than repeating the same code over and over again?

I have two different arrays set up one for fruit which has (orange, apple, stawberry) and I have another array with the numbers (1, 2, 3). I have jpg images for each of these combinations but how to I reference that in one line when I'm trying to refer to these images. I thought something like source = "[fruit].img.[number].jpg" would work

Again I've found some information on the web but it doesn't refer to how it would work if I was coding a source for my images.

View 2 Replies

Concatenate A Word With DIFFERENT Font In Dynamic Text Field?

Sep 19, 2010

I have a submit button that I'm pulling in from XML.

It needs to be XML because it is translated.

Therefore... the length is varying depending on the language.

I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)..

View 2 Replies

Flex :: Transform A String In Function And Concatenate With An Object?

Mar 2, 2010

I have the following code in actionscript 3:

var async:AsyncToken;
async = bridge.retornamenu();

The bridge is a remote object, instantiated. The retornamenu() is the function that I want the remote object open in amfphp.

However the retornamenu() is a dynamic function, which turns another function, but I can not run it at runtime,

example

var stringfunction:String = "retornamenu()" // this name is dynamic.
var async:AsyncToken;
async = bridge.stringfunction;

But this way does not work, not perform the function retornamenu();

View 1 Replies

ActionScript 2.0 :: Concatenate Two Strings As A Condition In A Case Statement?

Jun 14, 2010

I can't for the life of me come up with anything that works...

function setCurrentCMI(id){
if (_level0.strInteraction+id==""||_level0.strInterac tion+id=="undefined") {
//does nothing, user hasn't been here yet

[code]......

View 0 Replies

ActionScript 3.0 :: Possible To Concatenate A Word With DIFFERENT Font In Dynamic Text Field?

Sep 19, 2010

I have a submit button that I'm pulling in from XML.It needs to be XML because it is translated.Therefore... the length is varying depending on the language.I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)...

View 4 Replies

ActionScript 3.0 :: Concatenate A Word With DIFFERENT Font In Dynamic Text Field?

Sep 19, 2010

I have a submit button that I'm pulling in from XML.

It needs to be XML because it is translated.

Therefore... the length is varying depending on the language.

I simply want to add an arrow to the end of the word using Webdings #4 (it looks like a solid arrow, not like > but solid)...

View 1 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 :: 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

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 :: 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







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