ForumsProgramming ForumTo a minimum / maximum of...

2 2673
KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

Hi there folks, I've googled a bit for this but not had much luck. I was wondering if it's possible to assign numeric variables to have a minimum / maximum value, or else to increment them similarly in AS3.

e.g. i += j 'to a maximum of' x

It seems a bit clunky and bulky to correct this using if statements afterwards. (i.e. if i > x then i = x ).

  • 2 Replies
joeybetz
offline
joeybetz
107 posts
Shepherd

Just use the Math.min() and Math.max() calls. They work perfect for instances like this.

KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

That's perfect! Thanks.

Showing 1-2 of 2