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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentage in A.S. 1

Status
Not open for further replies.

dimmech

Technical User
Jan 20, 2004
34
0
0
US
I don't really know how difficult or easy this may be but instead of a specified value, how would I get this to work based on a percentage of the screen width.

onClipEvent (enterFrame) {
if (_root._xmouse < 50) {
setProperty("_root.sky", _x, _x+1);
}
if (_root._xmouse > 500) {
setProperty("_root.sky", _x, _x- 1);
}
xpos3 = math.floor(getProperty(_root.sky, _x));
if (xpos3 >=508) {
setProperty("_root.sky", _x, -630);
}
if (xpos3 <=-1210) {
setProperty("_root.sky", _x, -76);
}
}

-dimmech
 

Hello...

You can set up variables to hold the stage width info, and then reference whenever (or on the fly with no variables):

xPercentile = Stage.width/100
yPercentile = Stage.height/100

So for example, to reference 75% of the stage, you can just use something like this.

xPercentile*75

Doing the same thing with no variables will be done like this:

(Stage.width/100)*75

Anyways, that should do it for you, but you will have to adapt that to your code above. Hope it helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top