AHHH! Can't Concatenate!

ok, I have some variables, and I’ve tried nine ways to sunday to get them to load.

Here’s what I’ve got…

loadVariablesNum(“reader.txt”, 0);

this[client + newline + address + newline + city + ", " + state + " " + zip] = “business”;

// loads text into fields, creates new field based on store name & address

I’ve also tried this…

this[client + newline + address + newline + city + ", " + state + " " + zip] = business;

and this…

business = client + newline + address + newline + city + ", " + state + " " + zip;

and this…

business = “” add(client + newline + address + newline + city + ", " + state + " " + zip);

and a million other varients…

HELP, PLEASE…I’M GOING MAD! :scream:

you’re quite confused

First things first:
what is your text file?
what do you want to do with its contents?

exerpt from text file…

&client=B. Atman
&address=500 West Batcave Road
&city=Gotham
&state=NY
&zip=99412

I want to load the variables into a single variable, which is then dumped into a multiline dynamic text field.

the end hope is to have all the variables go into the “business” variable, like so…

business = (B. Atman) + newline + (500 West Batcave Road) + newline + (Gotham) + ", " + (NY) + "  " + (99412)

and will show up in the dynamic text field like this…

<center>B. Atman<br>500 West Batcave Road<br>Gotham, NY 99412</center>

  1. Your variables in the textfield will each contain a newline when loaded into flash. To prevent this, keep them all on one line or do this

&client=B. Atman&
&address=500 West Batcave Road&
&city=Gotham&
&state=NY&
&zip=99412&

  1. Your using MX so make use of the LoadVars object. This will let you load your variables into this one object and be able to access them from that.

Because you are LOADing variables in from an external source, the variables wont be loaded right away meaning you will NOT be able to access them directly after you call the variable loading command. You’ll have to wait a little while until they’re fully loaded into Flash. A LoadVars object helps us here with its onload. Heres an example:


identity = new LoadVars()
identity.onLoad = function(){
	business = this.client +"
"+ this.address +"
"+ this.city +", "+ this.state +" "+ this.zip;
}
identity.load("reader.txt");

This makes a loadVars instance called “identity” where the variables of the text file are loaded (from the load command) when loaded, the onLoad function is called and all those variables are put into the business variable in that format you specified. Now, assuming you have a dynamic textfield on the stage (pre-centered) with a VAR set to be business, it will then correctly display the name and address appropriately once the variables have successfully loaded into flash.

variable = "business",
    text = "B. Atman\r500 West Batcave Road\rGotham\r, NY\r  99412",

Ok, that’s what the variable says now, but what appears on the screen is this…

<center>
B. Atman

500 West Batcave Road

Gotham
</center>

Before you flame my obvious stupidity, I know I forgot the &…fixing now…

Extremely sweet…worked like a charm. I’ve got to send you a cookie. Ok, where exactly did my thinking turn south on this one? I was about to try to load them all into an array and try that, but…I’m babbling. Thanks again…I’m not worthy, etc.

ok, sorry to beat a dead dog, but I want to see what you think…

any way to get out of putting the & on the data?

here’s what I’ve got, and, of course, it doesn’t work…(NOTE: * added to prevent the board from messing with the code)

the text file…


color=#B50102
&font=Impact

&email=bman@thecave.com
&ephrs=Email the Cave!

&wsite=http://www.waynemanor.com/deepdarkcave
&sphrs=View Web Site!

&numbr=1 (800) BAT-CALL
&clint=B. Atman
&addrs=500 West Batcave Road
&hcity=Gotham
&hstat=NY
&zpcde=99412

&pctag=<*p align='center'>&
&ahtag=<*a href='&
&mttag=*mailto:&
&ittag=<*i>&
&cltag=*&' target='_blank'>&
&catag=&<*/a>&
&cctag=&<*/p>
&citag=&<*/i>&
&cftag=<*/font>&
&fopen=<*font color='&
&fmidl=&' style='&
&fclse=&'>&
&bdaid=&

the flash file…


identity = new LoadVars()
identity.onLoad = function(){
	business = pctag + fopen + color + fmidl + font + fclse + citag + clint + bdaid + "/n" + bdaid + hcity + ", " + state + "  " + zpcde + citag + cftag + cctag
}
identity.load("bman.txt");

tried this too, with no avail…


identity = new LoadVars()
identity.onLoad = function(){
	business = "<*p align='center'><*font color'&" + color + "&' style='&" + font + "&'>&" + ittag + "&" + clint + "&" + citag + "&<*/font></p>"
}
identity.load("bman.txt");

where am I messing up, or is it a point of where to start?

  1. ditch the html tags in the loaded variables. Thats unnecessary. You can add them in flash. str = “<i>" + a + "</i>”;

  2. the only way of getting out of not using the & at the end is by either putting all the variables on one line (as I mentioned before) or stripping the
    and \r tags off (removing them from) the variables once they are loaded into flash.

I wanted to be able to dynamically change the color of the text as well as the font style, that’s why I’m trying to make the ramshackle code.

If anyone else can help me on this one, I’d appreciate it.

Hey sen, how would you add Html tags to the flash string?

for example how would you bold “You are about to send this message”



message2send = "Hallo " + sender_name + " !"  + Newline + " You are about to send this message: " + Newline + message +  Newline + "Your E-mail is: " + Newline + sender_email;



Know it wasn’t for me, but here you go anyway.

message2send = “Hallo " + sender_name + " !” + Newline + " You are about to send this message: " + Newline + message + Newline + “<b>" + "Your E-mail is: " + Newline + sender_email + "</b>”;

remove *, of course.

i dont see any changed to the code i gave you??

::: i take that back, lol, went too early to the post lol, thanx dude :slight_smile:

its including the html tags in the flash movie, ?

in the onLoad you have to use this. to preceed the variables (see my first example)

you also need to escape your “=” in the text file, otherwise flash will try to make a variable out of it (or something)

= should be %3D