A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Converting 2.0 to 3.0

  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    1

    Smile Converting 2.0 to 3.0

    I'm trying to convert this to 3.0, anyone willing to help?



    Code:
    user1 = undefined;
    pass1 = undefined;
    Code:
    function registerUser(user, pass) {
    	//Create new load variables
    	register = new LoadVars();
    	registered = new LoadVars();
    	//PHP user/pass = the user/pass passed to this function
    	register.user = user;
    	register.pass = pass;
    	//Update the registration text.
    	error2.text = "Registering Details..";
    						error2.visible = true;
    		error2.alpha = 0;
    Tweener.addTween(error2, {alpha:1, time:1});
    Tweener.addTween(error2, {alpha:0, time:1, delay:2});
    	registered.onLoad = function(success) {
    		if(success) { //if successful connection
    		//if the error/success message parsed from php reads..
    		if(registered.err == "Registration Successful.") {
    			//we dont get variables from PHP in this function
    			//we only send them because w're resgistering data
    			//varibles are only passed to flash when we're logging
    			
    			//update register text with that of which PHP parsed
    			error2.text = registered.err;
    			
    		} else {
    			//if the registration was not successful (user exists)
    			error2.text = "Registration Failed.";
    					error2.visible = true;
    		error2.alpha = 0;
    Tweener.addTween(error2, {alpha:1, time:1});
    Tweener.addTween(error2, {alpha:0, time:1, delay:2});
    			
    		}
    			
    		}
    	}
    	//using sendAndLoad to pass to the data to PHP
    	//Using Method 'GET' (Obviously change the URL to your own)
    	register.sendAndLoad("http://thegolfgame.uphero.com/golfgame/data/register.php", registered, "GET");
    }
    
    function clickHandler2(event:MouseEvent):void {
    	registerUser(_user1.text, _root,pass1.text);
    	
    }

    Code:
    function loginUser(user,pass) {
    	//Create new load variables
    login = new LoadVars();
    logged = new LoadVars();
        //PHP user/pass = the user/pass passed to this function
    	login.user = user;
    	login.pass = pass;
    	//Update the login text.
    	_root.error1.text = "Submitting Details..";
    			error1.visible = true;
    		error1.alpha = 0;
    Tweener.addTween(error1, {alpha:1, time:1});
    Tweener.addTween(error1, {alpha:0, time:1, delay:2});
    	
    	logged.onLoad = function(success) {
    		if(success) { //if successful connection
    		//if the error/success message parsed from php reads..
    		if(logged.err == "Login Successful.") {
    			//Update the flash user/pass to that of which PHP parsed
    			_root.user = logged.user;
    			_root.pass = logged.pass;
    			//update the login text with that of which PHP parsed
    			_root.error1.text = logged.err;
    					error1.visible = true;
    		error1.alpha = 0;
    Tweener.addTween(error1, {alpha:1, time:1});
    Tweener.addTween(error1, {alpha:0, time:1, delay:2});
    			//Go to frame 2, the 'logged in' frame
    			trace("Account was successfully made, you may login!");
    		} else {
    			//if the login was not successful (wrong user/pass)
    			_root.error1.text = "Login Failed.";
    					error1.visible = true;
    		error1.alpha = 0;
    Tweener.addTween(error1, {alpha:1, time:1});
    Tweener.addTween(error1, {alpha:0, time:1, delay:2});
    		}
    			
    		}
    	}
    	login.sendAndLoad("http://thegolfgame.uphero.com/golfgame/data/login.php", logged, "GET");
    	
    }
    
    //Function which passes user/pass variables to PHP for registration
    
    function clickHandler(event:MouseEvent):void {
    	_root.loginUser(_root.user.text, _root.pass.text);
    
    
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    This should help you along with the register section, you can work out the "registered" section from this code too.

    you will need to add your tweener yourself, I believe its the caurina tweens.
    PHP Code:
    import flash.events.Event;
    import flash.events.MouseEvent;

    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLVariables;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequestMethod;

    import caurina.transitions.Tweener;

    var 
    registerLoader:URLLoader;
    var 
    regsiterRequest:URLRequest;
    var 
    registerVars:URLVariables;
    var 
    registerGood:String;

    var 
    user undefined;
    var 
    pass undefined;

    registerButton.addEventListener(MouseEvent.CLICKregisterUser);

    function 
    registerUser(event:MouseEvent):void
    {
        
    regsiterRequest = new URLRequest("http://thegolfgame.uphero.com/golfgame/data/register.php");
        
    regsiterRequest.method URLRequestMethod.POST;
        
        
    registerVars = new URLVariables();
        
    registerVars.user user;
        
    registerVars.pass pass;
        
        
    registerLoader = new URLLoader();
        
    registerLoader.dataFormat URLLoaderDataFormat.VARIABLES;
        
    registerLoader.addEventListener(Event.COMPLETEregisterComplete);
        
    registerLoader.load(regsiterRequest);
    }

    function 
    registerComplete(event:Event):void
    {
        
    trace("Made it here.");
        
    trace(unescape(event.target.data));
        
    registerGood event.target.data.err;
        if(
    registerGood == "Registration Successful.")
        {
            
    error2.text registerGood;
        }
        else
        {
            
    error2.text "Registration Failed.";
        }

    I can't decpiher whats coming back from the php file that you link to though.

    It's a good idea to attach all your files to save us from trying to work out how you have it set up.
    Last edited by fruitbeard; 09-02-2014 at 08:36 AM.

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