-
why does this work?
I know that this works:
Code:
clip.onPress = clip.onRelease = function () {
trace("yeah");
};
(both when pressed and released a trace occurs)
But I can't find anything about it in the help file WHY this is correct and why it works. Can someone lead me to the page where it says this is correct syntax for combining multiple event handlers into one? I can only find this one:
on (press, release) ...
-
Thats correct, on (press, release) is the old way
Im not sure what as3 is, anyone want to chime in?
-
I'm using Flash 8 and this works just as well. I don't get any error messages in the output window or while autoformatting. I can understand the logic behind it somewhat, but can't find anything in the help files that this kind of syntax is ok. Does is say anywhere this kind of format is acceptable?
-
This doesn't need to be documented as being correct, it just is.
You can do multiple assignments on one line...
PHP Code:
a = "abcd all have the same value"
b = "abcd all have the same value"
c = "abcd all have the same value"
d = "abcd all have the same value"
... can be rewritten as...
PHP Code:
d = "abcd all have the same value"
c = d
b = c
a = b
... and is the same as...
PHP Code:
a = b = c = d = "abcd all have the same value";
Whenever you make an assignment it is the value of that assignment that is returned. e.g. If you trace(d = "abcd all have the same value"); then you see that the value of d is traced out ("abcd all have the same value"). And so you can see how this multiple assignment kind of propagates from right to left.
In other words it's just a short hand way of assigning the onPress and onRelease function to the same function and at the same time.