# Convert a variable value to a name/string?

**URL:** <https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032>\
**Category:** flash\
**Created:** [June 25, 2003, 2:34pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032 "2003-06-25T14:34:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![keitai](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@keitai](https://forum.kirupa.com/u/keitai)\
**Post date:** [June 25, 2003, 2:34pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/1 "2003-06-25T14:34:15Z")

</div>

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

```auto

_root.xmlDocument.load(abc1234);

```

But i want to use

```auto

_root.xmlDocument.load(file);

```

Because the filename is auto generated.

Any tips

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 2:45pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/2 "2003-06-25T14:45:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:04pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/3 "2003-06-25T15:04:19Z")

</div>

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

```auto

_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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:14pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/4 "2003-06-25T15:14:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:25pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/5 "2003-06-25T15:25:44Z")

</div>

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:

```auto

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

```

and

```auto

_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 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:34pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/6 "2003-06-25T15:34:29Z")

</div>

you could try

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:37pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/7 "2003-06-25T15:37:29Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 25, 2003, 3:48pm UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/8 "2003-06-25T15:48:14Z")

</div>

gonna try your suggestions

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 26, 2003, 9:34am UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/9 "2003-06-26T09:34:03Z")

</div>

finally got it working.

With

```auto

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

```

thnks dravos.

One question, though. I thought i did this by

```auto

XMLtoLoad = String(file);

_root.xmlDocument.load(XMLtoLoad);

```

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

Grtz,

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 26, 2003, 10:13am UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/10 "2003-06-26T10:13:56Z")

</div>

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

Anyway, glad you got it working 😛

Dravos

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 9:57am UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/11 "2003-06-27T09:57:06Z")

</div>

Last question ( i hope),

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

```auto

_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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 27, 2003, 10:38am UTC](https://forum.kirupa.com/t/convert-a-variable-value-to-a-name-string/24032/12 "2003-06-27T10:38:27Z")

</div>

Doh… 😃 Glad you got it working anyhow… Happy Scripting…

Dravos
