开发者

navigating from one swf file to another

I have a swf file which requires a username and password to log in. When the user enters the values and clicks the submit button I validate it using asp.net. What I want is if the validation succeeds then I want to navigate to the home page of my application which is also a swf file. How can I do this? This is my mxml code

<?xml version="1.0" encoding="utf-8" ?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style source="d:/style1.css"/> 
<mx:HTTPService id="htservice" url="http://ramcovm354/MDCF/Upload.aspx" 
    fault="faultHandler(event)"
    result="resultHandler(event)"
    method="POST"
    />


<mx:Form id="myForm">
<mx:FormHeading label="Welcome to Bulk Upload Data - Home Page" />  
    <mx:FormItem label="Username" paddingLeft="开发者_开发技巧75" paddingTop="10" required="true" >
        <mx:TextInput id="username" width="100"  />
    </mx:FormItem>
    <mx:FormItem label="Password" paddingLeft="75" required="true">
        <mx:TextInput id="password"  width="100" displayAsPassword="true" />
    </mx:FormItem> 
    <mx:FormItem label="Doc Type" paddingLeft="75"  >
        <mx:ComboBox id="DocType" width="100" styleName="ComboBox">
            <mx:ArrayCollection>
                 <mx:String>MS Office</mx:String>
                 <mx:String>Open Ofiice</mx:String>
              </mx:ArrayCollection>  
         </mx:ComboBox>
    </mx:FormItem>
    <mx:FormItem  paddingTop="10" paddingLeft="75">

        <mx:Button id="mySubmitButton" label="Login" click="{validate();}" styleName="Button" />
    </mx:FormItem>                      
</mx:Form>

<mx:Script>     
    <![CDATA[
        import mx.controls.Alert;
        import mx.rpc.http.*;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.AsyncToken;
        import mx.rpc.AsyncResponder;
        import mx.rpc.events.FaultEvent;
        import mx.utils.StringUtil;
        import flash.display.*;
        import flash.net.URLRequest;
        import flash.net.navigateToURL;

        public var ldr:Loader = new Loader();
        public var address:String="http://ramcovm354/MDCF/mainpage.swf";
        //private function fieldValidator(evt:FocusEvent):void 
        //{
        //  Alert.show("Focus Lost","Alert.Box",Alert.OK);
        //}

        public function validate():void
        {

            var params:Object = {};

            if(username.text =="" || username.text== null || password.text=="" || password.text==null)
            {

                Alert.show("Username or Pasword Cannot be blank","Alert.Box",Alert.OK);

            }
            else
            {
                params["User"] = username.text;
                params["Password"]=password.text;
                params["docType"]=StringUtil.trim(DocType.selectedItem.toString());
                htservice.send(params);
            }


            //token.addResponder(new AsyncResponder(GeneratePreviewResHandler,faultHandler));
        }
        public function resultHandler(event:ResultEvent):void
        {   


            var urlReq:URLRequest = new URLRequest(address);
            //ldr.load(urlReq);
            //addChild(ldr);
            navigateToURL(urlReq);
            //Alert.show(event.result.toString(),"Alert.Box",Alert.OK);
            //txtSolutionName.text = event.result.toString();
        }

        public function faultHandler(event:FaultEvent):void
        {
            Alert.show(event.fault.faultDetail,"Fault",Alert.OK);
        }
    ]]> 
</mx:Script>    
</mx:Application>

Thanks in advance.


I'm making up what I think your server-side ASP.NET code looks like since you haven't provided any, but you should get the idea:

public void Login(string un, string pw)
{
   bool success = checkAgainstDbValues(un,pw);

   if(success)
   {
     Response.Redirect("myHomepage.html");
   }
   else
   {
     //do something if login fails.
   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜