FlashtodayÖ
- Started
- Last post
- 11 Responses
- honkytonk
hey, there's a bit of syntax in this .fla I don't understand...
AVar= (Math.ceil(_root._ymouse/_root.B... == num) ? true : false;
so AVar equals the y mouse position that's divided by BVar, but what does the rest mean? thanks all in advance...
- 4cY0
math.ceil rounds the number to the top (that's bad english? huh?)
here's what i mean:
3.45
would become
4
- honkytonk0
gotcha - what about the end part(the ? part...)
- mitsu0
that's a conditional operator
- 4cY0
not too sure, got an idea, but i am no expert...
anyway, keep it bumped till someone can explain..
- mitsu0
me=(bodyguard>enemy)?safe:dead;
- kpl0
what 4cy said plus:
the ? : construct is a conditional... like an if...else statement.
it works like this:(statement) ? (value) : (value);
if the statement evaluates as true (non-zero), then it returns the first value. otherwise, it'll return the 2nd value.
ie.
test = 1 ? "yep" : "nope";
//test equals "yep"so, nope, Avar doesn't equal a number... just true or false.
- kpl0
btw, I was enjoying myself when I started using one of these yesterday, then shortly broke down crying realizing what a nerd I was.
- honkytonk0
me+kpl=truelove.
thank you.
- b34r0
It looks like a test for the mouse position...
essentially the part that looks like this;
( condition ) ? true : false
is a 'short hand' way of writing an if /else statement.
Also the first part, assigns the outcome of the condition (either true or false in this case) to 'AVar'. You can assign conditional statements to variables, then use them in if/else statements.
So 'AVar' actually becomes true or false. This is probably tested later in the code...
if ( AVar ) {
// do something
} else {
// do something else
}
Math.ceil is what 4CY said.
HTH. : )
- mitsu0
kpl, if you start redirectig low-level io streams, then i'll have to buy you a pair of taped glasses.
- b34r0
kpl beat me to it, : )
nice one...* I'm a geek too.