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
Similar Posts:
Jul 19, 2006
I'm trying to achieve something i thought would be extremely easy, but i can't get it to work!
[Code]...
View 1 Replies
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
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
Apr 27, 2010
Is there any way to concatenate E4X expressions? If I store "half" a path in a variable, can I concatenate the way I do with Strings?
View 3 Replies
Sep 18, 2005
lets say that when you click on a button the variable number goes up 1 or 2 but it picks it randomly
how would i do it
[Code]...
View 8 Replies
Feb 20, 2008
i have a project and i need that when a specific variable equals a specific value a random number decreases on the current number, its easy to make it decrease but i need to decrease instead of 4 to decrease a maximun of 5 and minimun of 3.ere is the code :
Code:
numeroDeTazos = 20;
quantidade.text = numeroDeTazos;
if (nrfinal2 == 33)
{
[code]....
View 1 Replies
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
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
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
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
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
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
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
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
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
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
Mar 7, 2012
Im having an unusual problem tracking the value of a number variable....I have a number stored in a variable that changes up and down from 0 to 1 i.e. 0, 0.1, 0.2, etc, etc. This variable serves as an audio volume that is used with the soundTransform class.Im using the .text property for a text box:
ActionScript Code:
trackVolText_txt.text = Math.floor(_trackVolumes[1] * 10).toString();
And here is my volume down code, there is a volume up section that does the same job but reverse:
ActionScript Code:
function volumeDown(e:MouseEvent):void
{
if(_trackVolumes[1] < 1)[code].....
If I manually type in "10" in the text box to represent full volume so as soon as the .swf file loads it says "10" in the text box, I only get the readings: 10, 1 and 0. If I leave the text box blank, it will then increment and decrement 10,9,8,7,6,etc,etc.
My question is: can I somehow have a value manually typed into the dynamic text box without the above problem happening?
View 1 Replies
Mar 31, 2008
So I have a variable decalred as a number like this:
Code:
function foo(index:Number) {
index = 1;
..}
[Code]....
I am pulling my hair out, as it is standing in the way of me completing a project.
View 3 Replies
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
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
Jun 7, 2010
i have something like this in the frame:
var number1 = 10
var number2 = 10
And in the stage i have 3 dynamic text boxes. The 1 one has the variable number1 the secound one has the variable number2. But how do i do so in the third box it says 20? I want it to substract number1 and number 2 and show that in the box.
View 1 Replies
Mar 3, 2010
I create game matching things. If icon 1 == icon 2 then i delete this icons. Player finish game when he match all icons. I try give points for correct unswers. And try to calculate this poits.
code:
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
[Code].....
View 2 Replies
Feb 6, 2009
Let's say i want to removeChild a movie clip instanced name: mcLife3 But instead of doing the correct: Code: removeChild(mcLife3); I need to use another Number variable called bonusLife which in this case = 3 Code: removeChild(mcLife[bonusLife]); Doesnt work...can anyone please let me know the correct syntax,
View 6 Replies
Jul 28, 2009
I have made a variable and am trying to store it as a number that the user enters from an input text field. I am trying this, but it does not work:
var myNumber:Number = myTextField.text;
when i trace myNumber, it comes out blank. How do i get the variable to be the number that is typed in the myTextField?
View 9 Replies
Jan 9, 2010
Im trying to do a hittest on a random movieclip... basically i have 4 'objects' and i am picking a random number to pick one of them... this is all fine except when i try to do a hittest on 'object' + randomNum...Below is the code that works first with a trace that is kicking out the name i want, and below is the code ive tried but doesnt work...
Code:
var randomNum:Number;
randomNum = Math.round(Math.random()*3)+1;[code].......
View 2 Replies
May 1, 2011
I'm trying to find the answer to make appears a "000" value (with all three "0"s) and I can not find any answer around books/internet.var nPoints:Number= 000;trace(nPoints);In this way we only receive "0".
View 5 Replies
Oct 24, 2006
I have this to build my nav;
Code:
// navigation
var picNum:Number = 3;
for (var i = 1; i<=picNum; i++) {
_root.nav["btn"+i].topText_mc.text = [i];
_root.nav["btn"+i].alphaTo(30, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
}
My XML:
What I want is to get this trace(parseFloat(i)); to be my picNum variable. Tried a bunch of different things but none worked. Maybe someone here knows?
Code:
var pArray = new Array();
var tArray = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
[Code] .....
View 4 Replies
Aug 29, 2009
Once you load up your xml, how can you convert a certain node into a number variable?
View 2 Replies
Oct 30, 2009
Im running AS2 on Flash CS4 for this: I've found a million posts on similar topics, but none seem to do what I want, even though I feel like its very simple. I've tried a ton of different codes and can't get anything to work. All I want is for Flash to pull a number variable from an external file, lets just say a txt for now. I then want to be able to use this variable for calculations within flash. The only thing I can get to semi-work is having a txt file that says MyNum=5 and then putting the following in flash: loadVariables("Test.txt" , _root);
If I trace the variable "MyNum" it will output the right value, but its as a string no matter what I do. My most recent attempt to get it to be a number is to put the following on a later frame:
var NewVar:Number = MyNum;
var NewVar2:Number = NewVar + 1
trace(NewVar2);
Despite hardcoding multiple variables to be numbers, the output I get is 51, which means its still displaying as a string. My other issue is that you have to wait several frames before the variable is recognized. Do you have to wait numerous frames to use these loaded variables? If so, is there a way I can code it so that flash will just wait until it has the variable before moving on? I can't seem to get any loading function to work for it, but I don't just want to pull my next action down the timeline some arbitrary number of frames and hope its enough for flash to pull that number from the file.
View 10 Replies