Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

increment a number proportionally???

Status
Not open for further replies.

Jennyucf

Instructor
Jun 22, 2001
215
US
Hi, guys

Is there any way that I can increment a number proportionally, like from 500-1000, the number goes up drmatically fast;from 1000 to 1500, the number goes up less fast. The closer to 1500, the slower it is?

Please see my fla file here:

Thank you!
 
Hi,

Here's a really quick and dirty way to get the result you want. Create a clip containing a dynamic text box with the variable name "readout" and drop these clip events on to it. The first few iterations of the loop make really large jumps which slow down dramatically as the "readout" value approaches the "target" value.

(Also very cool if you add the line "this._x=readout/3;" before the last bracket :) )

onClipEvent(load){
difference=1500;
target=1500;
deceleration=1.05;
}

onClipEvent(enterFrame){
readout=math.round(target-difference);
difference=difference/deceleration;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top