Groups | Blog | Home
all groups > flash actionscript > november 2005 >

flash actionscript : Predetermined expressions



TruLine
11/21/2005 10:47:15 PM
Is there a way set an arry of expressions? At a point in my code I am checking
numerous varibles at one time, and I need to check also if the _xmouse and
_ymouse are within 1 of 8 different areas of the stage. As in this expression:

var mousePressPoint:Number = _ymouse;
"mousePressPoint < 720 and mousePressPoint > 600;"

I need to create an array or come up with another way with several of these
positions so I can loop thru them instead of having multiple if/elseif
statements, or switch statements.

Or, is it okay to have several pages of if and switch statements?? Looking
for the most efficient way to code for speed and resource.
NSurveyor
11/21/2005 11:01:09 PM
You could have an array of the two y coordinatess. Something like:

area =
[[0,120],[120,240],[240,360],[360,480],[480,600],[600,720],[720,840],[840,960]];

var mousePressPoint:Number = _ymouse;
for(var a=0;a<areas.length;a++){
if(mousePressPoint >= area[a][0] && mousePressPoint < area[a][1]){
trace("THE MOUSE IS IN AREA "+a+"!!!!!");
}
}
TruLine
11/21/2005 11:09:07 PM
NSurveyor
11/21/2005 11:34:11 PM
AddThis Social Bookmark Button