home *** CD-ROM | disk | FTP | other *** search
- package com.facebook.views
- {
- import com.facebook.events.FacebookEvent;
- import flash.events.Event;
-
- public class LoginWindow extends BaseWindow
- {
- public static const PATH:String = "http://www.facebook.com/login.php";
-
- public static const SUCCESS_PATH:String = "http://www.facebook.com/connect/login_success.html";
-
- public static const FAILURE_PATH:String = "http://www.facebook.com/connect/login_failure.html";
-
- public var sessionParams:String;
-
- public function LoginWindow()
- {
- super();
- urlVars.next = SUCCESS_PATH;
- urlVars.cancel_url = FAILURE_PATH;
- urlVars.v = "1.0";
- urlVars.return_session = true;
- urlVars.fbconnect = true;
- urlVars.nochrome = true;
- urlVars.connect_display = "popup";
- urlVars.display = "popup";
- req.url = PATH;
- distractor.text = "Logging In";
- distractor.x = width - distractor.width >> 1;
- distractor.y = height - distractor.height >> 1;
- }
-
- override protected function onLocationChange(param1:Event) : void
- {
- if(html.location.indexOf(SUCCESS_PATH) == 0)
- {
- this.sessionParams = html.location;
- dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_SUCCESS,false,false,true));
- close();
- }
- else if(html.location.indexOf(FAILURE_PATH) == 0 || html.location.indexOf("home.php") > -1)
- {
- dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_FAILURE));
- close();
- }
- else
- {
- html.width = html.height = 0;
- distractor.visible = true;
- }
- }
-
- override protected function onClosing(param1:Event) : void
- {
- dispatchEvent(new FacebookEvent(FacebookEvent.LOGIN_FAILURE));
- }
-
- public function connect(param1:String) : void
- {
- urlVars.api_key = param1;
- html.load(req);
- }
-
- override protected function onComplete(param1:Event) : void
- {
- distractor.visible = false;
- if(!closed)
- {
- width = html.width = html.contentWidth;
- height = html.height = html.contentHeight;
- distractor.x = width - distractor.width >> 1;
- distractor.y = height - distractor.height >> 1;
- }
- }
- }
- }
-
-