A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Critical LoadVars problem.....

  1. #1
    Member
    Join Date
    May 2005
    Location
    England
    Posts
    44

    Critical LoadVars problem.....

    Hi, im experencing a problem with sending and recieving data from an asp file on my web server

    I have this code in actions layer, frame 1 (there is 5 layers with 1 frame in each layer):

    Code:
    function GetData() {
    	var reply_lv = new LoadVars();
    	var send_lv = new LoadVars();
    
    	send_lv.pass = _root.pass_txt.text;
    	send_lv.sendAndLoad("asptest.asp", reply_lv, "POST");
    	reply_lv.onLoad =loadedNetVars; 
    						
    }
    
    function loadedNetVars(success){
    
    	if(success) {
    			_root.tc_txt.text = reply_lv.pass;
             	// operation was a success
             	trace(reply_lv.name);
    			
    
        } else {
       
             	trace("Error"); // operation failed
    
    			} 
    			
    }
    I call it from a button, on the click event

    Code:
    	_root.GetData();
    And i get undefined returned

    BUT

    WHEN I DELETED THE CODE ABOVE AND PUT IN:

    Code:
    						var reply_lv = new LoadVars();
    						var send_lv = new LoadVars();
    						
    						send_lv.pass = _root.pass_txt.text;
    						send_lv.sendAndLoad("asptest.asp", reply_lv, "POST");
    						reply_lv.onLoad = _root.loadedNetVars; 
    						
    						function loadedNetVars(success){
    
    	if(success) {
    			_root.tc_txt.text = reply_lv.pass;
             	// operation was a success
             	trace(reply_lv.name);
    			
    
        } else {
       
             	trace("Error"); // operation failed
    
    			} 
    			
    	}
    and that worked fine.

    Can anybody tweak my code to get it working for when i click button

    Thankyou


    P.S Another interesting thing, is that if I change

    Code:
    function GetData() {
    	var reply_lv = new LoadVars();
    	var send_lv = new LoadVars();
    
    	send_lv.pass = _root.pass_txt.text;
    	send_lv.sendAndLoad ( "asptest.asp" , reply_lv , "POST" );
    	reply_lv.onLoad = loadedNetVars;
    						
    }
    to

    Code:
    	var reply_lv = new LoadVars();
    	var send_lv = new LoadVars();
    
    	send_lv.pass = _root.pass_txt.text;
    	send_lv.sendAndLoad ( "asptest.asp" , reply_lv , "POST" );
    	reply_lv.onLoad = loadedNetVars;

    BUT that makes it work when the project loads, i need to be able to click a button to make it work
    Last edited by thomas49th; 08-27-2006 at 10:56 AM.
    And when a man gets to heaven;
    To saint paul he'll tell:
    1 more solider reporting sir,
    I've served my time on hell

    June 6th 1944

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I strongly recommend you not to associate any scripts with any objects but to put them on the main timeline:

    myBut.onPress = function()
    {
    function here
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    May 2005
    Location
    England
    Posts
    44
    lol i had just done that coming to forum to tell ive done it
    Thanks anyway

    Here is the final code

    Code:
    stop();
    loadVariables("SingupConditions.txt", this)
    _root.pass_mov._visible = false;
    _root.passen_mov._visible = false;
    outOfOrder_txt._visible = false;
    _root.username_mov._visible = false;
    _root.name_mov._visible = false;
    _root.tc_mov._visible = false;
    var reply_lv = new LoadVars();
    var send_lv = new LoadVars();
    
    _root.btn_sub.onRelease = function() { 
    
    	if (_root.tc_txt.text != "Error") {
    		
    		if ( _root.name_txt.text != "") {
    			
    			if (_root.username_txt.text != "") {
    		
    				if (_root.pass_txt.text == "") {
    			
    					_root.passen_mov._visible = true;
    					_root.pass_mov._visible = false;
    					_root.name_mov._visible = false;
    					_root.username_mov._visible = false;
    					_root.tc_mov._visible = false;
    		
    				} else if (_root.pass_txt.text != _root.chkpass_txt.text) {
    			
    					_root.pass_mov._visible = true;
    					_root.passen_mov._visible = false;
    					_root.name_mov._visible = false;
    					_root.username_mov._visible = false;
    					_root.tc_mov._visible = false;
    			
    				} else {
    					//Working fine
    					_root.pass_mov._visible = false;
    					_root.passen_mov._visible = false;
    					_root.name_mov._visible = false;
    					_root.username_mov._visible = false;
    					_root.tc_mov._visible = false;
    					
    					
    					//Check Terms And Conditions are checked
    					if (_root.tc.value != true) {
    						
    						_root.tc_mov._visible = true;
    						
    					} else {
    						
    						send_lv.pass = _root.pass_txt.text;
    send_lv.sendAndLoad ( "asptest.asp" , reply_lv , "POST" );
    reply_lv.onLoad = loadedNetVars; 
    
    						
    					}
    			
    				} 
    			
    			} else {
    				
    				_root.username_mov._visible = true;
    				_root.name_mov._visible = false;
    				_root.pass_mov._visible = false;
    				_root.passen_mov._visible = false;
    				_root.tc_mov._visible = false;
    				
    			}
    			
    		} else {
    			
    				_root.username_mov._visible = false;
    				_root.name_mov._visible = true;
    				_root.pass_mov._visible = false;
    				_root.passen_mov._visible = false;	
    				_root.tc_mov._visible = false;
    				
    		}
    						
    	} else {
    		
    		_root.outOfOrder_txt._visible = true;
    			
    	}
    }
    
    function loadedNetVars(success){
    
    	if(success) {
    			_root.tc_txt.text = reply_lv.name;
             	// operation was a success
             	trace(reply_lv.name);
    			
    
        } else {
       
             	trace("Error"); // operation failed
    
    			} 
    			
    }
    And when a man gets to heaven;
    To saint paul he'll tell:
    1 more solider reporting sir,
    I've served my time on hell

    June 6th 1944

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center