ActionScript 3.0 :: Turn Xml Into A Number Variable?
Aug 29, 2009Once you load up your xml, how can you convert a certain node into a number variable?
View 2 RepliesOnce you load up your xml, how can you convert a certain node into a number variable?
View 2 RepliesIs there a direct way how to turn a negative number to positive using bitwise operations in Actionscript 3? I just think I've read somewhere that it is possible and faster than using Math.abs() or multiplying by -1. Or am I wrong and it was a dream after day long learning about bytes and bitwise operations?
What I saw was that bitwise NOT almost does the trick:
// outputs: 449
trace( ~(-450) );
If anyone find this question and is interested - in 5 million iterations ~(x) + 1 is 50% faster than Math.abs(x).
I've come a long way with this sliding menu("Sliding menu.zip"). There's only one more thing that needs to be fixed. Can anyone tell me how to get the first movie clip button ("1") to be red when it arrives? When the user clicks on another button I want the red number one to turn black. It's sounds so simple but my mind is blank.
View 2 Replieslets 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]...
how I would turn a concatenated string into an array name so I can use it as an array?
I have this code:
ActionScript Code:
var waveNumber:Number = 0;
currentWave = "wave" + waveNumber;
trace(currentWave + [0]);
I am making a simple debugger window in ActionScript for myself where I can add and remove variables I want to track. I was to be able to add variables to the list by just doing something like
DebuggerMonitor.trackVar(variable).
My question is, is there any way I can turn "variable" itself (the name, not the value) into a String to be added into a text field?
I'm wondering if theres a way I can turn a variable of strings (separated by commas) into an array?I'm using the loadVars object to import variables from a text file that I'd like to import to flash as an array.For example if the variable I import from the text file looks like this:&myVar=charlie,dog,cat,test&I'd like to get it into an array in Flash like thismyArray = new Array["charlie","dog","cat","test"];
View 14 Repliesi 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]....
I'll start off by saying I'm a newbie, just putting that out there. How do you make a turn by turn multiplayer flash game? I don't know if an engine is made in AS3, PHP, Javascript, or whatever,I made my game already, it's just that it isn'tmultiplayer yet. Basically, there are lines, and each player crosses out a number of lines, and the last player to cross out a line is the loser. I want it where one user crosses out some lines, then presses End Turn, then the other does their turn and then presses End Turn to allow the other player to move his cursor. But how can I get both players to see the same frame and only have one player have the ability to move the cursor during a turn? Is there some easily adaptable multiplayer engine for flash for newbies out there
View 2 RepliesIm 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?
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.
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.
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].....
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 RepliesI 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?
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].......
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 RepliesI 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] .....
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()]);
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.
So what I have here is a button that will take away a random number from a variable (in this case being money) this is nothing more than a learning experience and I just wish to broaden my horizons on flash AS.
Actionscript Code:
on (release) { money -= random(200); }on (release) {gotoAndPlay (2);}
While this code works just fine the only problem i have with it is that it will select a number from (0-200). Is there a way I can set this up to select a random number BETWEEN 2 numbers? EX: (150-200)
I'm trying to duplicate a movie clip when a variable reaches a certain number.. this is the code I used...
if (numBlts<300) {
_root.power = 1;
_root.p += 1;
duplicateMovieClip(_root.plus, "plus"+p, p);
}
The problem is that I just want to duplicate it once everytime numBlts gets below 300. After numBlts increases above 300 and then goes below 300 I want the clip to duplicate. All its doing now is duplicating infinite times...
im importing a few variables with this [code]but now how do i make a variable say root.cash into a a number which can be used in equations or used for logical compariosons such as < > ==
View 2 RepliesSo I load a variable, length, into a LoadVars instance.
Code:
trace(this.length); //outputs 3
var tempLength:Number = this.length; //tempLength should be the number representation of the loaded value
thisObj.buttonLength = tempLength+2; //I need to add 2 onto the this.length value
trace(thisObj.buttonLength); //outputs 32, which kind of makes sense, but I need it to output 5.
thisObj.buttonLength is declared as a number, and Flash does not output a type mismatch.
Does anyone know, how to count the number of characters in a variable ?[code]...
View 2 RepliesIs there a way to get Flash to know what frame it's on and pass that as a variable? I can't use counters because I'm using a random frame function.
View 3 RepliesIs there a piece of code to test if a varibale is a full number?
[Code]...
I have several objects referencing one value in a number, and I need to tween this number but I cant figure out how.I'll use whatever, the built in tweens or tweener or anything.I cant figure out how to reference the value of the variable, since its not a display object and you cant just say myDisObj.y or something like that.If theres no way to do this i'll just have all of the display objects reference from one's property.
View 4 Repliesthe variable Im interested in is numSound which at the moment is a random number between 1 and 5, but it repeats too much and a sequence would be fine. I know very little actionscript and nothing I have tried works,the code, or what seems the relevant code, is
Code:
private function randRange(min:Number, max:Number):Number
{
[code].....
I want to add some input fields together and can't seem to do it..
test_btn.onRelease=function(){
total = Number(input1) + Number(input2);
}
In the total field I get 'NaN'