Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can i max a calculation value?

Guest
Jun 02, 2013 Jun 02, 2013

Hello.

I want to know how i can max a calculation to a certain value. In this case its about daysCal it should when it gets down to a negative number go back to 112 and continue the calculation from there. I hope someone can help.

var dpC:DataProvider=new DataProvider()

          var weeksCal = Number

          var yearsCal = Number

          var daysCal= Number

 

          daysCal= (Math.floor (days-weeksCount*7))

          yearsCal=yearsSb.value

          weeksCal=weeksNo-weeksCount

 

                    dpC.addItem({"Weeks Training": weeksCal})

  dpC.addItem({"Seasons Training":(weeksCal)/16})

                    dpC.addItem({"Age Training": Math.floor ((weeksCal)/16+yearsCal)+"y"+(daysCal+"d")})

 

          dgC.dataProvider=dpC

TOPICS
ActionScript
521
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 02, 2013 Jun 02, 2013

Describe the factors that are involved in the calculation and where they come from.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 02, 2013 Jun 02, 2013

I have tried this but when the sliders are used the calculation get negative after a 2 years. The first 2 years it works properly. What can cause this?

var dpC:DataProvider=new DataProvider()

          var weeksCal = Number

          var daysCal= Number

          daysCal= (Math.floor (days-weeksCount*7))

          weeksCal=weeksNo-weeksCount

             

                    dpC.addItem({"Weeks Training": weeksCal})

                                                    dpC.addItem({"Seasons Training":(weeksCal)/16})

                               if(daysCal<0){

                              years--

                              daysCal=daysCal+112

                              }

                    dpC.addItem({"Age Training": years+"y"+daysCal+"d"})

          dgC.dataProvider=dpC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 03, 2013 Jun 03, 2013
LATEST

This is a basic function that decremtns from a given value and resets it when it reaches a certain limit:

import flash.utils.*;

var counter:int = 112;

var _timer:Timer = new Timer(100);

_timer.addEventListener(TimerEvent.TIMER,timerHandler);

_timer.start();

function timerHandler(e:TimerEvent):void{

    decrementFromTo(112,0);

}

function decrementFromTo(_upperLimit:int,_lowerLimit:int):int

{

    if (counter>_lowerLimit)

    {

        counter--;

    }

    else

    {

        counter = _upperLimit;

    }

    trace(counter);

    return counter;

}

//try to apply this to your problem

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines