PDA

View Full Version : ASP session variables to Flash mx 2004


tazy7
11-30-2005, 12:57 AM
hi ppl,

i need to get a couple of session variables from an asp page into flash, onto display on to screen a username which is stored in a session variable and a directory root which is needed for to point a loadmovie function in the right direction. From what i understand i need to use loadvars and have found a post made by cota (http://www.actionscript.org/forums/showthread.php3?t=67379) to give me a start. As for the asp page side do i need to response write the session variables onto the page if so is this unsecure as the directory where i load an swf from is unavailable for certian users?

Basically then how to i get session variables from an asp page and what do i need to do to flash and the asp page to pass the variables?

many thanks
alex :)

Cota
11-30-2005, 03:35 AM
passing a session variable out shouldnt create any security issue's since you're doing it on purpose. Just like in the example, just use LoadVars and you'll be straight.

tazy7
11-30-2005, 02:36 PM
flash just doesnt want to know, below is my actionscript

myVars = new LoadVars();
myVars.load("alextest.asp");
myVars.onLoad = function(success) {
if(success){
anotherVariable = this.prefix;


}
}

status_txt1=anotherVariable;
stop();

on my asp page i have:


<!--#include file='includes/common.asp'-->
<!--#include file='includes/subgroup_options.asp'-->
<%

Response.Write"&prefix="&strUserName


%>

The username variable is showing perfectly well on the asp page but in the flash page the text field, status_txt1 is showing as undefined, any clues why this is happening?:confused:

thanks
alex

tazy7
11-30-2005, 04:13 PM
sortted it out, i moved the load class to the second line and on the success statement i have done a gotoandstop to show the information it seems to work cant work why tho, who am i to question why lol

Cota
11-30-2005, 04:27 PM
This should work

myVars = new LoadVars();
myVars.onLoad = function(success) {
if(success){
status_txt1.text = this.prefix;
}
}
myVars.load("alextest.asp");

stop();