
180 Create a Custom Component
6. Select the second Label control and enter Password as the value of its text property.
7. Select the first TextInput control and enter txtUID as the value of its id property.
8. Select the second TextInput control and enter txtPwd as the value of the ID text box and
true as the value of the Display As Password text box.
9. Insert a Button control below the second TextInput control and enter Login as the value
of its
label property.
10. Align and fine-tune the position of the controls so that the layout looks as follows:
Your code should look as follows (your coordinate values may vary):
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
width="275" height="150" title="Member Login">
<mx:Label x="10" y="12" text="Username"/>
<mx:Label x="10" y="42" text="Password"/>
<mx:TextInput x="74" y="10" id="txtUID"/>
<mx:TextInput x="74" y="40" id="txtPwd" displayAsPassword="true"/>
<mx:Button x="178" y="70" label="Login"/>
</mx:Panel>
11.
Save your file.
Define an event listener for the custom
component
In some cases, you want the custom component to contain logic that can handle user actions.
For your LoginBox component, you want the component to validate the user name and
password when the user clicks the Login button, and then submit the data for authentication.
Comentários a estes Manuais