<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
height="300" initialize="Format();">
<mx:Script>
<![CDATA[
import mx.events.NumericStepperEvent;
import mx.controls.Alert;
import mx.formatters.*;
public var nowCurr:Date = new Date();
public function timeChange(event:Event):void
{
//Alert.show(String(event.target.id));
if(event.target.id=="minutes"){
ti.text=dateFormatter.format(new Date(nowCurr.setMinutes
(event.target.value)));
if(event.target.value==60)
{
event.target.value=00;
event.target.text=dateFormatter.format(new Date(nowCurr.setMinutes(event.target.value)));
}
}
}
private function Format():void
{
dateFormatter.format(minutes.value);
Alert.show(minutes.value.toString());
}
]]>
</mx:Script>
<mx:DateFormatter id="dateFormatter" formatString="NN" />
<mx:NumberFormatter id="numFormatter" rounding="none" />
<mx:Canvas>
<mx:NumericStepper id="minutes" height="20" value="0" stepSize="15"
maximum="60"
change="timeChange(event);" creationComplete="timeChange(event);" borderThickness="0" width="43"/>
<mx:TextInput id="ti" width="25" editable="false"/>
</mx:Canvas>
</mx:Application>
You'll have to make the date formatter know that the minute is 0.Something like thisti.text=dateFormatter.format(new Date(nowCurr.setMinutes(event.target.value)));Hope this helps,-sam
On 8/29/06, Bruce Denham <[EMAIL PROTECTED] > wrote:I'm trying to use to make a numericstepper control display two zeroes
(00) instead of the single zero (0). I think the reason my current
attempts using a DateFormatter are failing is because I'm trying to
format a number as a string using formatString="NN", and the numeric
stepper is just ignoring it, I guess. But I looked at the
NumberFormatter, and didn't see anything useful other than precision
(which is the wrong side of the decimal for my needs).
Here's the code I'm trying to use:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" width="400"
height="300" initialize="Format();">
<mx:Script>
<![CDATA[
import mx.events.NumericStepperEvent;
import mx.controls.Alert ;
import mx.formatters.*;
public function timeChange(event:NumericStepperEvent):void
{
if(event.target.id=="minutes")
{
if(event.target.value==60)
{
event.target.value=0;
dateFormatter.format (event.target.value);
}
}
}
private function Format():void
{
dateFormatter.format(minutes.value);
Alert.show(minutes.value.toString());
}
]]>
</mx:Script>
<mx:DateFormatter id="dateFormatter" formatString="NN" />
<mx:NumberFormatter id="numFormatter" rounding="none" />
<mx:NumericStepper id="minutes" height="20" value="0" stepSize="15"
maximum="60"
change="timeChange(event);" borderThickness="0" y="118" left="195"
right="78" width="60"/>
</mx:Application>
Any help would be greatly appreciated.
Best,
Bruce
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Software development tool Software development Software development services Home design software Software development company
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
- [flexcoders] Setting NumericStepper to 00 for Minutes Bruce Denham
- Re: [flexcoders] Setting NumericStepper to 00 for Minut... Samuel Reuben
- Re: [flexcoders] Setting NumericStepper to 00 for M... Samuel Reuben
- Re: [flexcoders] Setting NumericStepper to 00 f... Samuel Reuben
Reply via email to