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); };
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");
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
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
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
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
Don't see what you're looking for? Try a search.
|