Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 11th, 2003, 08:00 PM
Buggy Buggy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: India
Posts: 6 Buggy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using sendAndLoad variables outside the function

This might seem like a silly problem to most of them but being a newbie I have been scratching my head over this. Can anybody tell me how can I get the value of uid in this code outside the function so that my other functions can use it too.

I have the following code.
But when I run the code.

I get the two traces:
21
undefined

Please inform me how can I get the userid value outside the function so that I can use it in all my other functions.
//=============================================
var userid;

function getuid()
{
mailsettings = sharedObject.getLocal("UserSettings");
myData = new LoadVars();
mydata.username = username;
mydata.pass = pass;
myData.sendAndLoad("getuid.php",myData,"POST");
myData.onLoad = getuser;
function getuser()
{
uid = this.useri;
userid = uid;
trace(userid);
}
trace(userid);
}

//=============================================

Thanks for the help in advance.

Reply With Quote
  #2  
Old August 13th, 2003, 11:55 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
userid is in the scope of your loadvars object so change to
trace(mydata.userid);

or set userid as a var on the main timeline or a global var.

Reply With Quote
  #3  
Old August 14th, 2003, 08:37 AM
Buggy Buggy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: India
Posts: 6 Buggy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Jamie

Hello Jamie,

I don't know how to get it working. Can you just send me an example using flash php so that I can actually get it working that would be really great of you.

Thanks in advance.

Reply With Quote
  #4  
Old August 14th, 2003, 08:50 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 56 m 16 sec
Reputation Power: 17
try
Code:
function getuid() { 
mailsettings = sharedObject.getLocal("UserSettings"); 
myData = new LoadVars(); 
mydata.username = username; 
mydata.pass = pass; 
myData.sendAndLoad("getuid.php",myData,"POST"); 
myData.onLoad = getuser; 
function getuser() 
{ 
uid = this.useri; 
_root.userid = uid; 
trace(uid);
} 
trace(userid); //this one should work - the var now exists on the main timeline
} 

_root makes your code less portable though.....better would be to use _parent

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Using sendAndLoad variables outside the function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway