# Using variable in a url

**URL:** <https://forum.kirupa.com/t/using-variable-in-a-url/17721>\
**Category:** Uncategorized\
**Created:** [April 8, 2003, 4:06pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721 "2003-04-08T16:06:35Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sozugk](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@sozugk](https://forum.kirupa.com/u/sozugk)\
**Post date:** [April 8, 2003, 4:06pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/1 "2003-04-08T16:06:35Z")

</div>

Hi,

Is it possible to have a hyperlink from flash and use a variable for a part of the url and not the whole url?

this is what I mean. Let’s say you have a page [www.abc.com/fruit.asp](http://www.abc.com/fruit.asp) and you want to send a fruit name to that url from a flash button and that variable will take you to the proper page for that fruit You want to have the static url ([www.abc.com/fruit.asp?fruit=](http://www.abc.com/fruit.asp?fruit=)) but at the end of it you you want to add a variable (apple) that is stored in the flash movie… Is it possible? Thanks.

---

<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:** [April 8, 2003, 4:16pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/2 "2003-04-08T16:16:18Z")

</div>

i don’t quite understand why you’d need a variable for the url and you can’t just put the URL in there. as far as I know there’s no way to make part of a URL a variable although I’ve learned with flash … where there’s a will … there’s a way.

maybe if you post a sample of the movie you’re working on and explain what you’re trying to do we can think of a good solution that you can do easily =)

---

<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:** [April 8, 2003, 4:19pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/3 "2003-04-08T16:19:28Z")

</div>

Sure you can add a variable in a URL 🙂

Here is an example… just throw this in flash and test the movie to see the outcome…

[AS]var myFruit = “apple”;  
trace(“[www.abc.com/fruit.asp?fruit=](http://www.abc.com/fruit.asp?fruit=)”+myFruit);[/AS]

As you see “[www.abc.com/fruit.asp?fruit=](http://www.abc.com/fruit.asp?fruit=)” is in double quotes, but myFruit is not. This defines “[www.abc.com/fruit.asp?fruit=](http://www.abc.com/fruit.asp?fruit=)” as as string, and then adds on the value of myFruit to the end of that string.

Just change the value of myFruit and the URL will change as well 🙂

---

<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:** [April 8, 2003, 4:34pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/4 "2003-04-08T16:34:19Z")

</div>

lol … wow for the first time i actually thought of that but i didn’t type it b/c i thought it was wrong … #$\*^!@$%!@%$\_Q)@#$ =)

you so cool beta

---

<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:** [April 8, 2003, 4:36pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/5 "2003-04-08T16:36:48Z")

</div>

ok here is why…

I’m actually trying to pass 2 variables to the asp file. However I one of the variables is static and the other is dynamic. Let’s continue with the same example above. I have 10 buttons for 10 colors. When you press the button, it will pass the color (which is static) and the fruit names(which is a dynamic variable that was passed into flash from another html file) Therefore I cannot pass the whole url.

If it’s still not clear, I will explain the whole project in detail. Thank you.

---

<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:** [April 8, 2003, 4:38pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/6 "2003-04-08T16:38:26Z")

</div>

lostinbeta, let me try that, yeah it had to be something like that but I didn’t know the format. I’ll try that thanks.

---

<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:** [April 8, 2003, 4:39pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/7 "2003-04-08T16:39:51Z")

</div>

sozugk: BTW: trace is a function in Flash just to check the value of something, trace in no way has to do with the actual URL, it is just to check to make sure the string came out correctly, it is used mainly for troubleshooting and checking in Flash. You would replace that with a getURL() when you actually want it to go to a page.

---

<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:** [April 8, 2003, 4:40pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/8 "2003-04-08T16:40:19Z")

</div>

yup it works… I was using & instead of + that’s why it didn’t work. Thanks everyone I appreciate it.

---

<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:** [April 8, 2003, 4:40pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/9 "2003-04-08T16:40:39Z")

</div>

Glad you got it fixed man:)

---

<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:** [April 8, 2003, 4:41pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/10 "2003-04-08T16:41:42Z")

</div>

ah one more thing… Is it possible to pass varible INTO flash, from a html variable? The same thing above but the other way around… Thanks. 🙂

---

<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:** [April 8, 2003, 4:42pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/11 "2003-04-08T16:42:35Z")

</div>

Yes… through Javascript, ASP, PHP, or XML you can pass a variable into Flash.

But server-side Flash is a weakness of mine, I can’t really help you much on that one ☹

Check out loadVars(), it should point you in the right direction.

---

<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:** [April 8, 2003, 5:11pm UTC](https://forum.kirupa.com/t/using-variable-in-a-url/17721/12 "2003-04-08T17:11:05Z")

</div>

thanks 🙂
