Adobe Dreamweaver Forums



Last 10 THreads :         Why is this not working!!! (Last Post : Boxing Boom - Replies : 11 - Views : 12 )           »          CF8 Enterprise gives 500 errors (Last Post : BJFranz - Replies : 0 - Views : 1 )           »          cfimage error (Last Post : masoud_amen - Replies : 0 - Views : 1 )           »          Flash Controls Not Displaying in Embedded File (Last Post : QADesign - Replies : 4 - Views : 5 )           »          Scollbar theme (Last Post : vcorey - Replies : 0 - Views : 1 )           »          Scollbar theme (Last Post : vcorey - Replies : 0 - Views : 1 )           »          Flash CS4 constant crashes (Last Post : san_flash - Replies : 5 - Views : 6 )           »          DIV in Table not working. (Last Post : Murray *ACE* - Replies : 11 - Views : 12 )           »          navigation bar in div (Last Post : jody25 - Replies : 2 - Views : 3 )           »          Disabling menu bars in a browser window (Last Post : Jay Jay - Replies : 6 - Views : 7 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-26-2008, 06:33 PM
GeorgeWS
 
Posts: n/a
Diggs:
Default Slider and date

I have a slider like so:

<mx:HSlider id="myslider" width="245" allowThumbOverlap="true" thumbCount="1"
snapInterval="1" tickInterval="1"
values="[11]" labels="['Jan', 'Dec']" minimum="1" maximum="12"
change="sliderChangeTwo(event)" dataTipFormatFunction="getSliderLabel"
themeColor="#73B9B9"/>

every month I go in and change the values to the current month like November
is 11. How can I have it shoe this month automatically. I have been looking at
the date stuff but there is an error because dates are strings and the slider
acceps numbers. Any thoughts?

Thanks
George




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-26-2008, 07:02 PM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Slider and date

This works:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.SliderEvent;

private var months:ArrayCollection = new ArrayCollection([
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December"
]);

private function getSliderLabel(num:Number):String{
return months.getItemAt(num-1) as String;
}

private function getCurrentMonth():Array{
return [new Date().getMonth()+1];
}
]]>
</mx:Script>
<mx:HSlider id="myslider" width="245"
tickInterval="1" values="{getCurrentMonth()}"
labels="['Jan', 'Dec']" minimum="1" maximum="12"
dataTipFormatFunction="getSliderLabel"
snapInterval="1"/>
</mx:Application>

Reply With Quote
  #3 (permalink)  
Old 11-26-2008, 08:03 PM
rtalton
 
Posts: n/a
Diggs:
Default Re: Slider and date

...and here's another way to do it...
View source at:
http://www.anaheimwib.com/_comps/slider/

Main difference is I'm using arithmetic on the current date to get you a date
one month out, and using the formatted result as a bindable in the slider
labels property. Since the "futureDate" var contains today's date + one month,
you could also use this var anywhere else in your code where you need the
entire future date. This is useful at the end of the current year, where you
might want to add two months to today's date, and get a date in 2009, for
instance.

I included the use of the Date formatter class to get you started on returning
just a portion of a date, formatted as you wish (M="1", MM="01", MMM= "Jan",
MMMM= "January"). Simply change the formatter's format string and the slider's
labels will also be updated.

On more thing...if you are planning on using the slider's retun value to get a
month's number, remember that in actionscript the month numbering starts at 0
(you are specifying 1-12; AS uses 0-11).

Complete code:



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="initApp()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
private var dateNowate = new Date();
private var futureDateate = new
Date(dateNow.getFullYear(),dateNow.getMonth()+2,da teNow.getDate());
private var minHSliderLabel:String;
private var maxHSliderLabel:String;
[Bindable]
private var sliderArray:Array;
[Bindable]
private var currentMonth:Number = dateNow.month+1;

private function initApp():void{
minHSliderLabel=myDateFormatter.format(dateNow);
maxHSliderLabel=myDateFormatter.format(futureDate) ;
sliderArray = [minHSliderLabel,maxHSliderLabel];
}
]]>
</mx:Script>
<mxateFormatter id="myDateFormatter" formatString="MMM"/>

<mx:HSlider id="myslider" width="245" snapInterval="1" tickInterval="1"
labels="{sliderArray}" minimum="1" maximum="12" themeColor="#73B9B9" y="26"/>

</mx:Application>

Reply With Quote


  #4 (permalink)  
Old 12-01-2008, 06:03 PM
GeorgeWS
 
Posts: n/a
Diggs:
Default Re: Slider and date

Greg,
Thanks alot. I have it working to select the current month. I cannot seem to
get it to start out that way. when the app loads it brings in the data, All
months are shown in my chart, and the correct month (Dec) is where the thumbs
is (so thats good) when I move the thumb to November it changes the chart
perfect. But when it loads there are all 12 months how can I get it to just
have December to start? When I move the thumb back to December it looks
perfect. Thanks for all your help.

George

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk