all groups > flash actionscript > march 2004 >
You're in the

flash actionscript

group:

please help with this simple "if" statement


please help with this simple "if" statement artane
3/12/2004 9:54:08 PM
flash actionscript:
hey guys,

I'm grabbing 2 variables from an ASP page and trying to use them in my flash
actionscript with a simple "if" statement. It doesn't work and I'm wondering
if the script is wrong. If not, then I'll know the problem is somewhere else.
Does the following look correct?

username = _root.user;
current = _root.current;

if (username == current) {
gotoAndPlay(1);
} else {
gotoAndPlay(2);
};
Re: please help with this simple "if" statement ldebono
3/12/2004 10:05:44 PM

Re: please help with this simple "if" statement Jack.
3/12/2004 10:41:44 PM
more than likely a timing issue, trying to use vars before fully loaded.
try this in a test movie, where variables "user" and "current"
are retrieved from your.asp

lv = new LoadVars();
lv.onLoad = function(){
trace(lv.user);
trace(lv.current);
username = lv.user;
current = lv.current;
if (username == current) {
trace("same")
} else {
trace("different");
}
};

lv.load("your.asp");
Re: please help with this simple "if" statement artane
3/13/2004 1:57:57 AM
hey guys,

I appreciate the advice, running a trace sounds like a great idea. The thing
is, I don't know how to do this.

Do I create a "test" movie and embed it with my .asp page? where do I put this
script. I'm a bit confused.

artane
Re: please help with this simple "if" statement artane
3/13/2004 3:52:12 AM
hey guys,

I've confirmed that I am passing the proper variables so, I'm sure it's a
problem with this script. I've also learned that the "==" can't be used
because my variables are not numbers so, my script now looks like this. Is
this correct?


function clearHistory() {
this.chat.clearHistory();
};
username = _root.user;
current = _root.current;

if (username eq current) {
gotoAndPlay(2);
} else {
gotoAndPlay(3);
}



Thanks alot,

artane
Re: please help with this simple "if" statement Jack.
3/13/2004 12:24:15 PM
your code syntax is OK, is it still not working ?
Note - as written, your if(condition){statement} is called once only
are all variables available when calling ?
perhaps place it in a loop to continuously poll for the condition

FWIW .. eq (equal-string specific) Flash Player 4.
Usage - expression1 eq expression2
where expression1, expression2 are Numbers, strings, or variables.

This operator has been deprecated since Flash 5
in favor of the == (equality) operator.
Usage - expression1 == expression2
where expression1,expression2 is
A number, string, Boolean value, variable, object, array, or function.

hth

Re: please help with this simple "if" statement artane
3/15/2004 10:18:21 PM
hey Jack,

Thanks alot, I needed to know that my script was ok. Turns out the problem
was within my asp page. I was grabbing the wrong variable (userNameLoggedIn
instead of UserName). I got it working now and everything is great!

Thanks again,

artane
AddThis Social Bookmark Button