Convert a variable value to a name/string?

I need some suggestions on this.

This my starting-point

1 I have to use a swf like: whatever.swf?file=abc1234
2 file=abc1234 represents the name of the xml file i need to load like


_root.xmlDocument.load(abc1234);

But i want to use


_root.xmlDocument.load(file);

Because the filename is auto generated.

Any tips

Ok i made a quick fla and then in the html replaced filename.swf with filename.swf?file=122. i made a dynamic text field with variable name file and saved/published.

When i opened the html document it read 122 in the text box, so this method should be ok

Hi dravos,

thnks for replying but that’s not what i am after. I know how to display/use a variable like that.

In your case the variable file has a value of 122 and i would like to load a xml file called 122 (i don’t use the xml exteension) with


_root.xmlDocument = new XML();
_root.xmlDocument.ignoreWhite = true;
_root.xmlDocument.load("122");

So i like to make 122 a string or text instaed of a value.

Sorry for my bad english.

Grtz

ok well the variable isnt a value or string, its not got a type really.

if you pass filename.swf?file=122.swf instead then you can use that in

[AS]_root.xmlDocument.load(file);[/AS]

or you could read filename.swf?file=122
and in the AS

[AS]file=file+".xml"
_root.xmlDocument.load(file);[/AS]

if you add the extension it makes it a string in a way

yep you right.

But for security reasons, i don’t know about, we/they don’t want to use extensions. I tried to load a .xml file without the xml extension and it works. ( I have the xml-file without the extension in the same folder)

So any “more” tips for my case?

I already tried:


_root.xmlDocument.load("\""+file+"\"");

and


_root.xmlDocument.load("file");

But in the latter case flash thinks it’s a xml file called file.

Also (abc1234).toString() gives me a undefined trace message. Is a letter and number combination to hard for flash?

Doesn’t do it for me :wink:

you could try

[AS]_root.xmlDocument.load(eval(file));[/AS]

yeah .toString is only used for objects not variables i think.

[AS]_root.xmlDocument.load(String(file));[/AS]

gonna try your suggestions

finally got it working.

With


_root.xmlDocument.load(String(_root.file));

thnks dravos.

One question, though. I thought i did this by


XMLtoLoad = String(file);

_root.xmlDocument.load(XMLtoLoad);

So what’s the difference and why won’t the second AS work??

Grtz,

if the first one was _root.file then the second one probably needs to be the same…

Anyway, glad you got it working :stuck_out_tongue:

Dravos

Last question ( i hope),

How can i load a file that is a directory higher.


_root.xmlDocument.load("../" +String(_root.file));


doesn’t worked.

Never mind got it working. i am so stupid - i forgot to load the xml on the my server a directory higher.

Doh… :smiley: Glad you got it working anyhow… Happy Scripting…

Dravos