I’ve used the random motion tutorial, and got that working. Now i’d like things to resize themselves depending on where they are on the screen… For example, if its at the very top, its 75% and if its at the bottom, 125%.
minsize = 75;
maxsize = 125;
dancerSize = _y;
if (bla bla bla, i got stuck at this point) {
dancer._yscale = dancerSize;
dancer._xscale = dancerSize;
}
As you can see, this divides the ._y value by the stage height and multiplies it by 100, thus giving you a percentage. The percentage is then divided by 2 and your minimum value of 75 is added. Finally, this new value is applied to both the ._xscale and the ._yscale of the movieclip to ensure that the scaling is constrained.
Some quick calculations demonstrate how the formula works:
when this.y = 0, this.yscale = 75 + ((0/200)*100)/2 = 75 + 0 = 75
when this.y = 100, this.yscale = 75 + ((100/200)*100)/2 = 75 + 25 = 100
when this.y = 200, this.yscale = 75 + ((200/200)*100)/2 = 75 + 50 = 125