Dan434
Dan434

Reputation: 71

AS3 Math.round issue

I need the variable value of 'speed' to be coming through as a whole number so it can affect the slide position of my 'BG' movieclip. After using this code (and trying many other variations), the 'round' variable only comes through as 0 or 1. (This code is all in the ENTER FRAME function.)

var speed:Number = (xspeed + yspeed) / 100;
var round:Number = Math.round(speed);

BG.gotoAndStop(speed);
texta.text = ""+(round);

Upvotes: 0

Views: 200

Answers (1)

Marty
Marty

Reputation: 39456

Well, you're diving by 100 so there's a high likelyhood that your number is actually between 0 and 1 (if xspeed + yspeed is ever less than 100, speed will be less than 1 after dividing by 100).

What do you get when you trace(speed)?

Upvotes: 1

Related Questions