Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Import Variable, String => Integer



i have a txt file and a variable in it called &maxNum=4

When i import it in flash, i can't work with it as a number. I suppose it is a string. Anybody know how to convert maxNum to a number?



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-26-2005, 10:00 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Change Variable From String To Integer
okay, heres the problem, i thought it'd be a nice simple clean script, but it didn't turn out to be.

Code:
on (release){
_root.output = _root.input + 1;
}
what i want it to do is add one to the input text box, and display it in the output box. eg.
you enter input as 5 and output displays 6.

but the problem is, it reads input as a string and just adds 1 to the end of it. eg.
you enter input as 5 and output displays 51. then 511 then 5111... etc.

can anyone help me? ive tried doing something like:
Code:


Code:
on (release){
a = _root.input;
b = a + 1;
_root.output = a;
}
but that didnt work either. please help!

String Into An Integer
Hi,

Simple thing I think

I have movieclips with instance names 1,2,3 etc and need to grab their names ( this.name = this._name ) but this becomes a string.

How do you convert a string into an integer.

Thanks in advance

String To Integer
I have the following readout from php
&id=1&name=jshpro2&score=2&max=11&level=1&connecte d=2


2

which works perfectly from flash, loads the variables and all but as strings, score+=5 for example when score=1 returns 15 when it should be 6 etc... how do i take a string and treat it as an integer?

String To Integer
Hey guys,

basically I need a code to convert an Integer to a string.

I have a string, (str) which is "5" for example, I want to add one to that number, but still keep it a string. I had the idea to change it into an integer, add one, then change it back to a string.
I used the code:

parseInt(str);
str++
parseString(str);

Unfortunatly I don't thing parseString is a real function!

any tips on how I could do this?

Thanks.

String To Integer
does any1 knows how to convert a string into a integer please thanks

Integer To String?
am trying to pass variables either from an external TXT file or from the HTML into flash. The passing seems to be working. The problem is that the variable that I'm trying to pass is an integer (ie. 9999) and I am trying to eventually concatenate a URL string with this variable to make one URL (ie. 'getURL(generalURL+passedinURL,"_blank");'). I tried using this code prior to the getURL:
var passedinURL:String = String(passedinINTEGER);
But it gave me the same error when the button was clicked on the website.
Can anyone help me out??

Thanks in advance!
Chaz

(I've posted this exact same message to the Actionscript forum already.)

Integer To String?
I am trying to pass variables either from an external TXT file or from the HTML into flash. The passing seems to be working. The problem is that the variable that I'm trying to pass is an integer (ie. 9999) and I am trying to eventually concatenate a URL string with this variable to make one URL (ie. 'getURL(generalURL+passedinURL,"_blank");'). I tried using this code prior to the getURL:
var passedinURL:String = String(passedinINTEGER);
But it gave me the same error when the button was clicked on the website.
Can anyone help me out??

Thanks in advance!
Chaz

Value Is A String Or An Integer
I've just seen a statement like this.


Code:
if (_root.map._width>"3000") {
_root.map.larger = 0;
}
Why 3000 put in quotes. Does it consider as a string on this expression?

My Integer Is A String
I use the php with flash.

In my php i put
***************************
$mynumber=10;
echo "SomeInteger=".$mynumber;
***************************

The problem is when i use loadvariables, it doesn't take the number as an integer, but a string. Therefore i cannot make any calculations. Can anyone help me..

Converting A String To Integer
I have a text file with a load of values (numbers) which control the position of a movieclip. When the value is imported into Flash it sees it as a string, but I want it as a number. I've tried converting using the parseInt(); function and also the Number(); but with no success. Doesn't anyone know if there is another way.

loadVariablesNum ("test.txt", 0);
// Value from the test.txt file

amount = Number(mcNumber);
while (amount>0) {
duplicateMovieClip (_root.mcBubble, "mcBubble"+i, i);
setProperty ("mcBubble"+i, _x, 200 + random(40));
setProperty ("mcBubble"+i, _y, 100 + random(46));
i = i+1;
amount = amount-1;
}

Loadvariables String To Integer
I tried changing a variable passed through loadvariables to a number.

credit = "1000" is what is being passed.

when I do Number(credit); it gives me 0
when I do int(credit); it gives me 0
when I do ParseInt(credit); it gives me NAN


Anyone have any ideas please????
thanks

Convert Integer To String
edit ----

sorry all, didn't notice the 30 trillion other posts explaining this issue.

oops!

Convert String To Integer
Is there a way (function) to convert a string to an integer?

Thanks!

How To Change A String To Integer ?
Can any one plz tell me that how to change a string value to integer in Flash. Infact i m receiving a varialbe from php file which is in string form. i want to change this to integer. Plz Help ...

Converting A String To An Integer
I'm loading some data from an external .txt-file.
In the .txt-file i have this:
number=40
I want to manipulate the number like this:
newNumber = this.number+1;
...in order to get the new number to be 41, but when I load the number from the .txt-file it is loaded as a string (am I not right?).
How do I convert the number to be an integer instead of a string, so I can manipulate it?

Converting A String To An Integer
I'm loading some data from an external .txt-file.
In the .txt-file i have this:
number=40
I want to manipulate the number like this:
newNumber = this.number+1;
...in order to get the new number to be 41, but when I load the number from the .txt-file it is loaded as a string (am I not right?).
How do I convert the number to be an integer instead of a string, so I can manipulate it?

Converting A Number In String To An Integer...
I'm reading in values from an external text file but they are being seen as strings rather than numbers so I can't do any calculations with - which I need to do!

How do I convert from a string to a usable number?

m.

Get Character, Out Of String And Turn It Into An Integer, How To?
Hi,

I generate comboboxes on the stage for user input! The amount of comboboxes can go from 3 to n where n can be anything.

The comboboxes recieve a name like :
Combobox1
Combobox2
..
ComboboxN


Later I want to get the last character(being the number) and turn it (back) into an integer.
Getting the number(as a string) is not a problem:
number = charAt(8)

Is there a way to turn the number-variable from a string to an integer?

Send Integer As String With GetURL
Hi
I have two questions. I'm trying to make a slider that sends integer values as strings through getURL to javascript. Here is my script ....

code:
slider_mc.top = slider_mc._y;
slider_mc.bottom = slider_mc._y;
slider_mc.left = slider_mc._x;
slider_mc.right = slider_mc._x+100;
slider_mc.knob_btn.onPress = function() {
startDrag(this._parent, false, this._parent.left, this._parent.top, this._parent.right, this._parent.bottom);
dragging = true;
};
slider_mc.knob_btn.onRelease = function() {
stopDrag();
dragging = false;
};
slider_mc.onEnterFrame = function() {
if (dragging == true) {
slice = Math.ceil((slider_mc._x-9)/(100/11));
display = slice;
if (slice integer value changes ) {
getURL("javascript:tb_DoFSCommand(slice as string , '0');");
}
}
};

The red parts are my problem. The slider works fine and I'm getting integer values coming up in the text field 'display'. What I need for slice value changes is something like 'when slice value becomes a different integer'.
The second part - sending the integer as a string - I haven't a clue. I've read about GET/POST in help, but I'm not sure how I can use them in this case. I just need that integer 'slice' to be sent as a string when and only when 'slice' becomes a different integer.

Can anybody help me? Is there a better way to do this?

thanks
mark

FlashMX2004Pro

Flash Thinks Integer = String?
Im having a most curious error. I made a script that on press adds one to a variable, and then some dynamic text is set to become that variable amount.

I used:
Score = (Score+"1")

The problem is, flash seems to treat my variable as a string, but i want an integer, any help would be nice -,-.

[F8] Reformat Integer To Money String
I'm working in flash 8 and as1.

I'm using this code that I found on the web..

Basically I'm just reformatting an integer to a money formatted string. The thing this code doesn’t do is add commas to the number. (Example: 1000 will return $1000.00)

Does anybody know how I may update this code to include commas in its output?

Thanks!



PHP Code:



function moneyFormat(num){
        valor = String (Math.round(num * 100) / 100);
        dot = valor.indexOf(".");
        money = "$";
        if(dot == -1){
                valor += ".0";
        }
        temp = valor.split(".");
        addDecimals = 2 - temp[1].length;
        for(i=1; i<= addDecimals; i++){
                valor += "0";
        }
        return money+valor;
};

Converting Input String To An Integer
Hi
Ok i wanted to do calculator baed in flas but got some problems
The input text filed send the string and I need to use it as interger for Math.sin() function.

I tried to use parseInt(ang) where ang is the input variable, but that didnt work either (i reied to parse 8 as input )

Any one knows how can i convert input strings to an integers that would work?

PS: I'm running Flash 8

Array.sortOn With String And Integer Flawed..
I'm using the sortOn method to sort my array.

concider this array:
var list:Array = new Array();
list.push( {id: "1"} );
list.push( {id: "4"} );
list.push( {id: "12"} );
list.push( {id: "23"} );
list.push( {id: "9"} );
list.sortOn("id");

This will return the following:
1, 12, 23, 4, 9
because the sorting happens on the first digit. so 12 is first, than 4
-------------------------------------------

this can be fixed by using the following sort:
var list:Array = new Array();
list.push( {id: "1"} );
list.push( {id: "4"} );
list.push( {id: "12"} );
list.push( {id: "23"} );
list.push( {id: "9"} );
list.sortOn("id", Array.NUMERIC);
This will return the following:
1, 4, 9, 12, 23
which is fine
-------------------------------------------

But when you decide to use an id that consists of a string + integer, this way of working doesn't work anymore . . .

var list:Array = new Array();
list.push( {id: "fubar1"} );
list.push( {id: "fubar4"} );
list.push( {id: "fubar12"} );
list.push( {id: "fubar23"} );
list.push( {id: "fubar9"} );
list.sortOn("id");

and

var list:Array = new Array();
list.push( {id: "fubar1"} );
list.push( {id: "fubar4"} );
list.push( {id: "fubar12"} );
list.push( {id: "fubar23"} );
list.push( {id: "fubar9"} );
list.sortOn("id", Array.NUMERIC);

Will both return:
fubar1, fubar12, fubar23, fubar4, fubar9


How can this be fixed? I want my sort to have the following result:
fubar1, fubar4, fubar9, fubar12, fubar23


I think this is a pretty big shortcoming of the sortOn method

Variable And Integer
Hi, could someone please tell me what I'm doing wrong? It is not recognizing xmlArrayDate[i]

Here's my script:

i=1
xmlDate = xmlDay + xmlMonth + xmlYear;
xmlArray["xmlDate"] = xmlDate;
xmlArrayDate[i] = xmlArray["xmlDate"];
trace(xmlDate);
trace(xmlArray["xmlDate"]);
trace("Date: " + xmlArrayDate[i]);

Here's what I get for output:

1312004
1312004
Date:

How Do I Test A Variable Is An Integer?
Hi,

I want to validate that a value in a form field is less than 50 and a integer. Ive got the less than 50 bit working but dont know how to test that the variable is an integer - anyone? Here's the code:

on (press) {
if (no_of_slides > 50) {
gotoAndPlay ("50 error");
}


Cheers..John

How Do I Test That A Variable Is An Integer?
Sorry if this is a bit lame, Im still getting my nose wet in programming!

Anyway, I need to test that a variable is an integer and display an error message, I suppose its something like:

if (var != (integer) )
gotoAndPlay ("error");

Integer Variable Comparison
I feel embarrased to post this !!

Why when the value of a is 1 (as seen with trace statement) it executes the code witin the 'IF' statement?



Code:
var a:Number = 0

if (a == 0)
{
var randNumber1:Number = Math.pow(-1, Math.floor(Math.random()*2));
var randNumber2:Number = Math.pow(-1, Math.floor(Math.random()*2));
this._y += this.randNumber1;//move it on the y axis at the set speed
this._x += this.randNumber2;//move it on the x axis at the set speed
++a;
trace(a);
}

Check If A Variable Is Integer
how can I check if a variable is integer or not?

Check If A Variable Is Integer
how can I check if a variable is integer or not?

Integer? Number? Variable Size
I have products codes that are made of 12 digits
when I make a search with
IF myvariable=102104101915
ELSE IF myvariable=102104101915
ELSE IF myvariable=181060512302
....
flash doesn't give me the right result because it consider only the beginning of the number.

I am not exactly familiar about how many digit can contain a flash variable
when I use typeof, it return "number"
so it is a type "number"
is the number of digit limited?

light welcome
françoise

Convert Float Variable To Integer?
Can anyone help me convert a variable to a real number?

My variable is reduced to 75% here:
var clength = drop*0.75;

but it has decimals.

Any help would be greatly appreciated.
Thanks
b o s s a n o v a

How Do I Forcibly Output A Variable As An Integer.
Gidday,

I have a problem with some code where it will not output exactly what I want.

Here's a direct code copy of what I am trying to do. I think it might just be a syntax problem, but for the life of me cannot work it out.


Code:
var textFileData:LoadVars = new LoadVars();

textFileData.onLoad = function(){
minNum_txt.text = textFileData.minNum; //minimum number specified for range
maxNum_txt.text = textFileData.maxNum; //maximum number specified for range


// Choose N numbers from a list of M numbers (ranging from 0 - M-1)

M = (textFileData.maxNum - textFileData.minNum);
N = 1;
ary = [];

for (i = 0; i < M && N > 0; ++i)
{
if (random(M-i) < N)
{
ary.push(i);
N--;
}
}
trace(ary);
display = ary;
}

textFileData.load("numberRange.txt"); //loads the txt file to read variables from
Any help would be greatly appreciated!
Cheers.

Import Vriable From URL String
i have a basic flash question that i cant seem to find the answer to anywhere....

i have a URL: http://www.something.com/index.html?refer=JOEJOE

the refer=JOEJOE is virtual and changes depending on where the user comes from.

index.html contains the embeded flash movie.

i want the movie to simply load the following URL:
http://www.something.com/newpage.html?refer=JOEJOE


what i have so far is:
------------

var refer = new LoadVars();
refer = "JOEJEO-this is what i need to replace";

getURL ( "http://www.something.com/newpage.html", "_self", "get" );

-----------

i need to replace the refer = "joejoe"; with the Actual virtual refer string...

in ASP it would be:
http://www.something.com/newpage.asp?refer=<% Response.Write(Request.Querystring("refer")) %>

but i cant seem to fina an equivalent in flash....

any suggestions would be appreciated!

Joe Rubin

#include To Import A String?
Hi,

I'm trying to pull out random words from a string. Converting the string to an array and then pulling the words out randomly is fine. My problem comes with having the string as a seperate text file that I'm trying to import using #include, the string of words is big, so I thought it would be better to have it seperate and then import it. This is what I have so far "words.as" is the seperate text file


ActionScript Code:
#include "words.as"

newName = "words.as";
name = newName.split (",");
one_btn.onRelease = function () {
    word_txt.text = name[ranNum];
    word01_txt.text = name[ranNum01];
    ranNum = Math.floor (Math.random () * name.length);
    ranNum01 = Math.floor (Math.random () * name.length);
};

Import Image From Query String
I have a file with the name “get-image.swf” and place it in a HTML-dokument. I use the file path “http://www.mysite.com/get-image.swf?45” (or ?id=45). So I want get-image.swf to load the image http://www.myside.com/images/45.gif with the “loadMovie-function”. Else if the path is “http://www.mysite.com/get-image.swf?76”, I want get-image.swf to load the image http://www.myside.com/images/76.gif. Someone understanding me?

PS: All the images are GIF-files.

Can Trace String But Cannot Set String To Variable
Hi,

I am importing a some text values from a text file and then trying to pass this value via a function

I can TRACE the text value successfully but cannot set it to a variable.

************************************************** **************
function test(){
var aTestVariable

myData = new LoadVars()
myData.load("thenews.html")
myData.onLoad= function(success){

if(success){
trace(myData.Title); //THIS WORKS
aTestVariable = (myData.Title);
}
}
return aTestVariable
}

function testFunction() {
trace(test()); //THIS DOES NOT WORK!
}
************************************************** **************


Can someone please tell me what is wrong with this:


trace(myData.Title); //THIS WORKS
aTestVariable = (myData.Title);

HELP!

Rich

How To Store A String Plus A Variable In A Dynamic Text Variable?
Hi,

I've got a dynamic text field with the instance name rightAnswer_txt.

I declare the variable in the frame it resides in, with the following code var rightAnswer_txt:String = "";

Then, when I want to populate it using the following code:

rightAnswer_txt.text = "You scored " + rightAnswers;

the script comes out with an error saying ...

**Error** Scene=Scene 1, layer=actions, frame=7:Line 15: There is no property with the name 'text'.
rightAnswer_txt.text = "You scored " + rightAnswers;

Any idea what this means anyone please?

How Do I Convert A String Variable Into A Number Variable?
How do I convert a string variable into a number variable?

Thanks in advance.

Garry

Change String Variable To A MovieClip Variable
Hi

I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.

I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.

When I trace "drawingCanvas" I get

[object drawClass]

which is fine. Tracing drawingCanvas.name gets me the instance name

'drawingCanvas'.

This is a String variable.

Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.

The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :

TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.

I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).

Any ideas are most welcome. I'm sure I am missing something obvious.

Thanks for looking

Convert String Variable Into Movieclip Variable?
I have a variable called something like city_str which has a value of "toronto". I also have a moveclip (exported for AS) called toronto_mc.

What I want is a way of concatenating strings of "toronto" and "_mc" and assigning it to a movieclip variable called toronto_mc. Everything I try gives me a mismatch error in the compiler. I'm writing AS2 using Flash CS3. Any ideas?

Import Txt With Variable
Hi,
A quick question. Can this work?

myvariable=Math.round(Math.random()*10000);
loadVariablesNum("text.txt?var="+myvariable, 0);

I'm receiving an error:
Error opening URL "file:///D|/text.txt?var=1950"



Thanks.

Samall

Variable Import?
Ok, I have two .swf files. One has a variable


Code:
Pagetitle = "News";
In the other .swf theres a dynamic text box with a variable called "Pagetitle".

When i import one .swf to the other, i want the variable to be read and displayed. But depite my efforts, i cant get it working.

Any ideas?

Urlformencoded Variable Import
OK,

i have a text file from which i import serveral variables with
loadvariable......

Textfile looks like this:
text1=blablalabl&text2=blablabalbla..........

Works fine.......but then i have the following url which i want to import as a variable:

url=http://www.something.com/detail.php3?hID=7&mID=462

as you can see the url contains serveral &´s which makes flash think its another variable !

is there a way to import that url as a whole ???

Thank you !

Import PHP Variable From URL Into Flash, Can It Be Done?
so lets say i have a page "page.php" which has a flash file embeded in it.

Then say I do "page.php?show=15"

Is it possible to grab the variables from the URL and use them in flash?

I'd rather not read from a seperate file...

Import Text From File TO A VARIABLE
Hey!

I was looking around, and couldnt find any solution for my question, even in Flashkit or Google, then I decided to post it here...

I was thinking if is possible to import text from an external file (txt straight format), NOT to a textbox, but to a variable.

The explanation is simple: I DONT want to display this imported text, but just check what's there (just like a config file or something like this, got it?).

Someone knows if it's possible and how to do that?

Thank you!

(urgent) Help On Variable / Import To List
code:
var swords=0;
var total=50;


total is max 50 least 0, swords can be brought up to 50, least 0. as you can see by my button

code:
on (release) {
if (total>0 && swords<50) {
swords++;
total--;
}
}





what i need help on is figuring out how to make certain skills import into a list format

example: swords 5, total points 45

when swords is raised to 5 ,i need a import command that adds "X SKILL"
to "Y LIST"

note: the list i want the skill to appear in is right on the char builder page.

its a character builder and i have searched endlessly for tutorials, i cant find nething on somthing like this.

PLEASE HELP!

Import Web Page HTML As A Variable
I was curious if there is a way to load the HTML code of a Web Page into a string variable. From there I could strip it down to it's basics using function like indexof and substring. Then display it's contents in a textbox.

Import Text File With No Variable
Normally, when importing a text file through LoadVars you would have to format the txt file like this:

content=This is de line which people should read

So it would have to start with a variable.

Is there a way to do this without the txt file needing to start with a variable? So the txt file would just contain the text?

This is the line which people should read

I guess not with LoadVars (it needs a variable), but perhaps in another way?

Copyright © 2005-08 www.BigResource.com, All rights reserved