2011-05-31 100 views
0

我是gigya服務,使用社交服務登錄登錄我的網頁。Gigya服務不能在Flex4中工作,但它在Flex3中工作正常

在我的flex 3中,一切正常,但是當我將代碼更改爲flex 4時,我無法看到正在加載的任何gigya服務。

我的代碼如下:

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:flexlib_controls="flexlib.controls.*" 
       xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       verticalAlign="middle" horizontalAlign="center" width="400" height="150" layout="absolute" 
       backgroundColor="#FFFFFF" borderStyle="none" color="#FFFFFF" backgroundGradientAlphas="[0,0]" 
       backgroundAlpha="0" applicationComplete="init()" 
       verticalScrollPolicy="off" horizontalScrollPolicy="off" fontFamily="Arial" fontSize="12">  

    <fx:Script> 
     <![CDATA[      
      import c7.config.ServerConfig; 

      import com.adobe.serialization.json.JSON; 
      import com.hurlant.crypto.*; 
      import com.hurlant.crypto.hash.HMAC; 
      import com.hurlant.crypto.symmetric.ICipher; 
      import com.hurlant.util.Base64; 
      import com.hurlant.util.Hex; 

      import flash.net.navigateToURL; 

      import mx.controls.Alert; 
      import mx.core.Application; 

      import mx.rpc.events.ResultEvent; 

      import spark.components.supportClasses.ListBase; 

      private var loginEventObj:Object = new Object(); 
      private var currentUID:String = new String();   
      private var userInfo:UserInfo = new UserInfo(); 
      public var currentResult:ByteArray; 
      public var secretKey:String = ServerConfig.get_gigya_key().secret_key;   

      // Define a configuration object. Insert your APIKey below: 
      private var conf:Object = { 
       APIKey: ServerConfig.get_gigya_key().api_key 
      }; 


      [Bindable] 
      private static var RPC_URL:String = ServerConfig.get_rpc_base_url();    

      [Bindable] 
      private var system_message:String = null; 

      private var newUserFlag:Boolean = true; // lets assume the user is new first. 

      private function init():void 
      {    
       initSocialService(); 
      } 


      private function initSocialService():void 
      {    
       Security.allowDomain("cdn.gigya.com"); 
       Security.allowInsecureDomain("cdn.gigya.com"); 

       // Initialize the "mcRoot" attribute of the conf object - should refer to the root of the flash container. 
       this.conf.mcRoot=this.root; 

       // Load Social service 
       // Create the load-parameters object 
       var loadParams:Object = { 
        services:'socialize', 
        callback:onServiceInit 
       } 

       // Load the service 
       gigya.load(conf,loadParams); 
      } 

      // Wait for the load to complete and handle failures/success 
      private function onServiceInit(response:*):void 
      { 
       if (response.hadError)   
        throw new Error('Failed to init gigya service');     
       else 
       { 
        gigya.services.socialize.addEventHandlers(conf, {onLogin:onLoginHandler}); 
        showLoginUI(); 
       } 
      } 

      private function showLoginUI():void 
      {    
       // Define parameters object: 
       var params:Object = {width: 350, 
        enabledProviders: "facebook, twitter, yahoo, messenger, google, linkedin, myspace, aol, openid", 
        height: 80, 
        lastLoginIndication: "welcome",      
        showTermsLink: false, 
        showWhatsThis: true,       
        hideGigyaLink: true, 
        container: loginCanvas, // embed component inside loginCanvas container 
        UIConfig: '<config><body><background frame-color="#BFBFBF" background-color="#FFFFFF" corner-roundness="5;5;5;5"></background></body></config>', 
        cid: 'login page'}; 
       gigya.services.socialize.showLoginUI(conf, params); 
      } 

      // Note: the actual signature calculation implementation should be on server side 
      private function verifyTheSignature(UID:String, timestamp:String, signature:String): void 
      { 
       //trace('Your user ID: ' + UID + '\n timestamp: ' + timestamp + '\n signature: ' + signature); 
      }              
     ]]> 
    </fx:Script> 
    <fx:Style> 
     .textInput{ 
      fontFamily: Arial; 
      color: #333333;     
      fontSize: 14; 
      paddingTop: 2; 
      paddingBottom: 2; 
      paddingRight: 2; 
      paddingLeft: 2; 
      cornerRadius: 5; 
      borderStyle: solid;    
     } 
     .smallText{ 
      fontSize: 10; 
      fontFamily: Arial; 
      color: #4483af;   
     } 
    </fx:Style> 
    <mx:ViewStack id="vs_main" width="100%" height="100%" top="0" left="0" borderStyle="none" paddingLeft="0" paddingTop="0" paddingRight="0" 
        paddingBottom="0" backgroundAlpha="0" creationPolicy="all" verticalScrollPolicy="off" horizontalScrollPolicy="off"> 
     <s:NavigatorContent id="bx_login" width="100%" height="100%"> 
      <s:Group id="bx_login1" width="100%" height="100%"> 
       <s:Label id="both_required_error_lbl" text="Both username and password are required" top="2" left="2" color="#ff0000" visible="false"/> 
       <s:Label id="invalid_error_lbl" text="{this.system_message}" top="2" left="2" color="#ff0000" visible="false"/> 
       <flexlib_controls:PromptingTextInput prompt="username" width="150" maxChars="100" id="txt_username" top="22" left="2" 
                color="#000000" enter="authenticate(txt_username.text, txt_password.text)" styleName="textInput"/> 
       <s:Label text="forgot username" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true" 
         click="{vs_main.selectedChild= bx_forgot_username;}" top="49" left="2"/> 
       <flexlib_controls:PromptingTextInput prompt="password" width="150" maxChars="100" id="txt_password" styleName="textInput" top="22" left="160" 
                color="#000000" displayAsPassword="true" enter="authenticate(txt_username.text, txt_password.text)"/> 
       <s:Label text="forgot password" styleName="smallText" useHandCursor="true" mouseChildren="false" buttonMode="true" left="160" top="49" 
         click="{vs_main.selectedChild=bx_forgot_password;}"/>   
       <s:Button id="btn_login" label="Submit" click="authenticate(txt_username.text, txt_password.text)" fontFamily="Arial" fontSize="12" 
          toolTip="Login using your existing account" color="#000000" top="22" right="2"/> 
       <s:Group id="loginCanvas" height="80" width="100%" left="2" bottom="2"/> 
      </s:Group> 
     </s:NavigatorContent>  
    </mx:ViewStack> 
</mx:Application> 

有人可以plz幫助我解決這個問題。

問候 Zeeshan

+0

您是否嘗試過調試?它在哪裏失敗?有沒有HTTP請求出去?有沒有錯誤? – 2011-06-01 14:34:51

回答

0

的Gigaya服務是行不通的,因爲Spark組件的。我沒有理由爲什麼spark s:Group不支持gigya,但是如果我保留flex3 mx:Canvas組件來完成這項工作,它可以完美運行。

相關問題