
CHAPTER 6
More Flex Applications
This chapter will show some sample Flex applications to dem-
onstrate
various aspects of Flex development. You can use
these examples as templates for your own applications.
A Runner’s Calculator
Anyone who has taken up running as an exercise knows the
pain of pushing to go too far too fast. It’s commonly held wis-
dom that you should start at 1 mile and then go 10% farther
every week. So, if you want to run 3.1 miles (5K) you should
be training for 12 weeks.
To help calculate that number I’ve come up with a handy help-
er application written in Flex. The first draft of the code is
shown in Example 6-1.
Example 6-1. Runner.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="onMilesChange(event)">
<mx:Script>
<![CDATA[
private function onMilesChange( event:Event ) : void {
var miles:Number = parseFloat( txtMiles.text );
var mile:Number = 1.0;
var weeks:int = 0;
79
Kommentare zu diesen Handbüchern