MACROMEDIA FLEX-GETTING STARTED WITH FLEX Bedienungsanleitung Seite 96

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 148
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 95
while( mile < miles ) {
weeks += 1;
mile *= 1.1;
}
txtWeeks.text = weeks.toString();
}
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label="Target Miles">
<mx:TextInput id="txtMiles" change="onMilesChange(event)"
text="3.1" />
</mx:FormItem>
<mx:FormItem label="Weeks">
<mx:Label id="txtWeeks" />
</mx:FormItem>
</mx:Form>
</mx:Application>
The application is split into two pieces. The calculation func-
tion, onMilesChange, is located at the top of the script. The user
interface is a form containing a text input for the number of
miles and a label for the number of weeks. There is an event
handler on the creationComplete event from the application
which calls onMilesChange to do the initial calculation. There
is also an event handler on the text field that calls onMile
sChange whenever the change notification is fired.
Figure 6-1 shows the runner’s calculator on startup.
I can change the target number of miles and watch as the num-
ber of weeks changes as a result. Figure 6-2 shows what hap-
pens when I change the target miles to 2.5.
It’s nice to know the number of weeks, but what if I want to
create a training calendar? I need to know the number of miles
for each week as I go. I actually calculated the data I need in
the onMilesChange function already; I just need to store it and
display it somewhere. So, I’ll update the Flex code a little bit,
as shown in Example 6-2.
80 | Chapter 6:More Flex Applications
Seitenansicht 95
1 2 ... 91 92 93 94 95 96 97 98 99 100 101 ... 147 148

Kommentare zu diesen Handbüchern

Keine Kommentare