Before we start the tutorial, let us explain how our navigation works. We have what we call a guid (globally unique identifier) which controls a users session. A guid is generated every time a user comes to the website. This guid is unique for every user and it has an expiry time of about 2 hours.
Question: What do you mean the guid expires? How should I know when the guid has expired?
Answer: The guid is usable until about 2 hours of idle time from the start of your session. Which means that if a user for some reason leaves their computer without logging off it stays logged in. Obviously you do not want it to stay logged in for ever, this is the reason for which the guid expires. If the user was to come back to the computer after the 2 hours, they will be prompted to log back in. This ensures the security of the login access.
Okay, so what does the guid have to do with Flash? Every URL in our system has to have a guid parameter added to it in order for the page to be displayed. if there is no guid specified, then the system will not know who you are. A common URL in an INS system looks like the following:
Since that the guid is generated every time a user comes to the site, you cannot hard code links into your flash, otherwise the links will break as the guid would have expired after the 2 hours. If you are familiar with the macros in the web-editor, you can use the following link to generate the guid.
This link does not work anywhere else but for internal pages of the system. So with a bit of background knowledge, we can proceed with the tutorial.
- Download the following ActionScript Class here: http://mlmsoftwaremanual.com/tiki-download_file.php?fileId=9|QueryString.as
- This class must be imported into your movie that you want the links to be on. So to import the ActionScript use the following code.
/* Added in new actionscript to parse parameters correctly */
import QueryString; //Imports Querystring.as
var qs:QueryString = QueryString.getInstance();
var guid = qs.getValue("guid"); //Sets Variable guid so that it can be used in function.
/* End of Query String. */
Let us take you through the steps of the above code, along with explanation for the same:
- import QueryString This line imports the QueryString.as making the class available to your movie.
- var qs:QueryString = QueryString.getInstance() - This line is used to creates an object.
- var guid = qs.getValue("guid") - This line sets the variable guid to get the value from the URL.
Now that you have the guid from the URL, you can use this variable in your links in your movie. An example of a link in your movie will look like this.