function - Actionscript 3 - Setting multiples of a number equal to a number -


i writing program in actionscript 3 involves slider displays weeks , months on course of year slide right in format of "month 2 week 3" or "month 8 week 2". did months this: function monthhandler(){

var a:number = ((math.ceil(aslider.value/4))+1); monthlabel.text = "month" + string(a);  } 

however same slider (aslider) i'd display weeks, 4, each month. know need set number threshold; values 1-4 display weeks: 1-4, values 5-8 have display weeks 1-4.

i know using crapton of if() loops relatively new programming , assuming there more efficient way of doing this, , not know it. looked around web checking multiples of numbers, , setting number thresholds, nothing seems suited problem.

the current code weeks is:

function weekhandler(){ var b:number = ((math.ceil(aslider.value/12))+1); weeklabel.text = "week:" + string(b); } 

all display 1-4 slide slider across quarters of thing. said, know doesn't work don't know fix it.

assuming slider had 12-months, 4-weeks per month:

months:

var months:int = (int)(dateslider.value / 4); 

weeks:

var weeks:int = (dateslider.value % 4) + 1; 

flash example:

flash-slider

if had dateslider flash component:

flash-date-slider

you update datetext label such as:

import fl.events.sliderevent;  dateslider.addeventlistener(sliderevent.change, sliderchangehandler);  function sliderchangehandler(event:sliderevent):void {     datetext.text = "month: " + (int)(event.value / 4) + " " +                     "week: " + ((event.value % 4) + 1); } 


flex example:

month-0 month-6 month-12

<?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"                xmlns:s="library://ns.adobe.com/flex/spark"                xmlns:mx="library://ns.adobe.com/flex/mx">      <s:layout>         <s:verticallayout />     </s:layout>      <s:label text="month: {(int)(dateslider.value / 4)} week: {(dateslider.value % 4) + 1}" />      <s:hslider id="dateslider"                maximum="{(13 * 4) - 1}"                snapinterval="1"                stepsize="1" />  </s:application> 

it should noted interpretation of dates seems rudimentary, actual number of weeks per month 4.34812.

explicitly calculating date timespans beneficial.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -