MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guide de l'utilisateur Page 182

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 256
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 181
182 Create a Custom Component
6. Enter the following code in the CDATA construct:
private function handleLoginEvent():void {
lblTest.text = "logging in...";
//login logic
}
In a real application, the handleLoginEvent function would reference or contain the
logic for validating and submitting the login entries for authentication. Developing the
logic for the handler is outside the scope of this lesson.
The keyword
private specifies the functions scope. In this case, the function is available
only within the component. If you set the scope to
public, the function is available
throughout your code.
The keyword
void specifies the functions return type. All ActionScript functions should
specify a return type. The
handleLoginEvent function returns no value.
The code for the component should look as follows:
<?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:Script>
<![CDATA[
private function handleLoginEvent():void {
lblTest.text = "logging in...";
//login logic
}
]]>
</mx:Script>
<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" click="handleLoginEvent()"/>
<mx:Label x="74" y="72" id="lblTest"/>
</mx:Panel>
7.
Save the file.
Use the custom component
The next step is to add the custom component to your MXML application file, and then to
compile and run the application file to test the component.
1. In Design mode, switch to the Main.mxml file.
Vue de la page 181
1 2 ... 177 178 179 180 181 182 183 184 185 186 187 ... 255 256

Commentaires sur ces manuels

Pas de commentaire