Using variable in a url

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 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=) 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.

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 =)

Sure you can add a variable in a URL :slight_smile:

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=”+myFruit);[/AS]

As you see “www.abc.com/fruit.asp?fruit=” is in double quotes, but myFruit is not. This defines “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 :slight_smile:

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

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.

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.

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.

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

Glad you got it fixed man:)

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. :slight_smile:

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 :frowning:

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

thanks :slight_smile: