
</mx:Form>
<mx:ProgressBar
visible="{app.loginPending}"
indeterminate="true"
label="{statusMessage}"/>
</s:Panel>
2. Replace the default ActionScript code in the Script component with the following code, which is similar to the default code but
has logic to handle status changes.
import com.salesforce.events.LoginFaultEvent;
import com.salesforce.events.LoginResultEvent;
import com.salesforce.events.SessionExpiredEvent;
import com.salesforce.events.StatusChangedEvent;
import mx.controls.Alert;
[Bindable]
private var statusMessage : String = "";
private var _username : String;
private var _password : String;
protected function loginClickHandler( event : MouseEvent ) : void {
_username = username.text;
_password = password.text;
app.loginByCredentials( _username, _password );
}
protected function statusChangedHandler( event : StatusChangedEvent ) : void {
trace( "status change: " + event.message.description );
statusMessage = event.message.description;
}
protected function loginFailedHandler( event : LoginFaultEvent ) : void {
event.preventDefault();
Alert.show( event.faultString, "Login failed." );
currentState = "login";
}
protected function loginCompleteHandler( event : LoginResultEvent ) : void {
currentState = "main";
}
protected function sessionExpiredHandler( event : SessionExpiredEvent ) : void {
// Alert will be shown if default is not prevented.
event.preventDefault();
app.loginByCredentials( _username, _password );
}
3. Add the AccountsView component to the end of the Main.mxml file, just before the closing WindowedApplication
tag. Your local namespace includes this component. The component does the following:
12
Step 7: Create the Account Manager Login Screen
Commentaires sur ces manuels