home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / com / facebook / views / LoginWindow.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  2.4 KB  |  78 lines

  1. package com.facebook.views
  2. {
  3.    import com.facebook.events.FacebookEvent;
  4.    import flash.events.Event;
  5.    
  6.    public class LoginWindow extends BaseWindow
  7.    {
  8.       public static const PATH:String = "http://www.facebook.com/login.php";
  9.       
  10.       public static const SUCCESS_PATH:String = "http://www.facebook.com/connect/login_success.html";
  11.       
  12.       public static const FAILURE_PATH:String = "http://www.facebook.com/connect/login_failure.html";
  13.       
  14.       public var sessionParams:String;
  15.       
  16.       public function LoginWindow()
  17.       {
  18.          super();
  19.          urlVars.next = SUCCESS_PATH;
  20.          urlVars.cancel_url = FAILURE_PATH;
  21.          urlVars.v = "1.0";
  22.          urlVars.return_session = true;
  23.          urlVars.fbconnect = true;
  24.          urlVars.nochrome = true;
  25.          urlVars.connect_display = "popup";
  26.          urlVars.display = "popup";
  27.          req.url = PATH;
  28.          distractor.text = "Logging In";
  29.          distractor.x = width - distractor.width >> 1;
  30.          distractor.y = height - distractor.height >> 1;
  31.       }
  32.       
  33.       override protected function onLocationChange(param1:Event) : void
  34.       {
  35.          if(html.location.indexOf(SUCCESS_PATH) == 0)
  36.          {
  37.             this.sessionParams = html.location;
  38.             dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_SUCCESS,false,false,true));
  39.             close();
  40.          }
  41.          else if(html.location.indexOf(FAILURE_PATH) == 0 || html.location.indexOf("home.php") > -1)
  42.          {
  43.             dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_FAILURE));
  44.             close();
  45.          }
  46.          else
  47.          {
  48.             html.width = html.height = 0;
  49.             distractor.visible = true;
  50.          }
  51.       }
  52.       
  53.       override protected function onClosing(param1:Event) : void
  54.       {
  55.          dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_FAILURE));
  56.       }
  57.       
  58.       public function connect(param1:String) : void
  59.       {
  60.          urlVars.api_key = param1;
  61.          html.load(req);
  62.       }
  63.       
  64.       override protected function onComplete(param1:Event) : void
  65.       {
  66.          distractor.visible = false;
  67.          if(!closed)
  68.          {
  69.             width = html.width = html.contentWidth;
  70.             height = html.height = html.contentHeight;
  71.             distractor.x = width - distractor.width >> 1;
  72.             distractor.y = height - distractor.height >> 1;
  73.          }
  74.       }
  75.    }
  76. }
  77.  
  78.