PDA

View Full Version : How can I make a positive number result it's negative equivalent?



LittleFenris
November 15th, 2007, 09:34 AM
I have a movieclip scroller that figures out how long the movieclip is (thumbnails load into the movieclip from an xml file, so the height of the movieclip will change when more pics are added), then only scrolls as far as it needs to get to the bottom of the movieclip. That works fine, cause even when I add more thumbnails to the movieclip and make that movieclip longer, the scroller compensates and moves it the extra length, the only problem is the result is always a positive number so its always moving the y of the movieclip down when you scroll down and not up like I need it to.

As you probably know when you scroll the scrollbar down, the thumbnail movieclip should technically be going up to work like a normal scrolling element does. How can I force the positive number to be its negative equivalent?

Basically if the result that Flash figures out with the math is 54, how do I make that -54 so the y of the movieclip moves up instead of down?

Thanks

Dazzer
November 15th, 2007, 09:35 AM
var y:int = 54;
var negative:int = -y;

LittleFenris
November 15th, 2007, 09:56 AM
var y:int = 54;
var negative:int = -y;


I'll give that a shot in my code, thanks Dazzer.

Dazzer
November 15th, 2007, 09:59 AM
Yeh even if that fails , you can do 0-y.

LittleFenris
November 15th, 2007, 10:15 PM
Yeh even if that fails , you can do 0-y.

The -y approach worked like a charm, thanks!

Here's the site I'm working on that the scroller is for:

http://www.littlefenris.com/GrapeSeed/