Fun with flex
Submitted by benl on Sun, 02/15/2009 - 18:42
Related Terms :
So I'm working on the Absurdist Manifesto, which is to be the world's coolest phone tree to nowhere.
First, I started a new flex project in Eclipse configured with Adobe Flex Builder.
Then, I quickly pieced the front-end view of a keypad together in flex.
<mx:Label text="The Absurdist Manifesto" id="debugger" />
<mx:HBox>
<controls:PhoneButton label="1" />
<controls:PhoneButton label="2" />
<controls:PhoneButton label="3" />
</mx:HBox>
<mx:HBox>
<controls:PhoneButton label="4" />
<controls:PhoneButton label="5" />
<controls:PhoneButton label="6" />
</mx:HBox>
<mx:HBox>
<controls:PhoneButton label="7" />
<controls:PhoneButton label="8" />
<controls:PhoneButton label="9" />
</mx:HBox>
<mx:HBox>
<controls:PhoneButton label="#" />
<controls:PhoneButton label="0" />
<controls:PhoneButton label="*" />
</mx:HBox>The PhoneButton I import with import com.colingolabs.controls.PhoneButton;
That code extends the standard flex button, like so:
package com.colingolabs.controls
{
import flash.events.MouseEvent;
import mx.controls.Button;
import mx.core.Application;
public class PhoneButton extends mx.controls.Button
{
public function PhoneButton()
{
super();
super.addEventListener(MouseEvent.CLICK, selectNumber);
}
private var option:Number;
private function selectNumber(event:MouseEvent):void {
option = event.target.label - 1;
Application.application.getOptions(option);
}
}
}Man I am really digging flex :)