views:

1282

answers:

2

When a user click a link, it would redirect them to a page, something like:

www.domain.com/index.php?var=string

Is it possible in AS3 to grab the variable (var)??

(I know there are alot of ways to get the variable, for example, php $_GET, but my website is purely flash based, I dont want to use php to get the value and store it in session and pass it to others pages. ANd I could not store in form and pass it to others pages, because the main button is in Flash, so I need to use AS3 to pass the variable).

+1  A: 

Check out this tutorial on using FlashVars as a parameter in your <object> code. Basically, you could use PHP or Javascript to get the variables from the address string and then insert them into the <param> FlashVars tag.

John Nicely
Also, you might find this official documentation from Adobe helpful: http://kb2.adobe.com/cps/164/tn_16417.html
John Nicely
Thanks for the link. I googled, but didnt found this link though. Well, it would take me a while to read and implement it. If its success, I would vote your answer as the best answer of this question
A: 
import flash.external.ExternalInterface;

var urlStr:String = ExternalInterface.call('window.location.href.toString');

This call asks JS to give you the current page url.

You can then parse it to extract the variables. Example at http://manfred.dschini.org/2008/05/12/as3-url-class/.

Daniel