syntax_icals BIG QUESTIONS

ok this is just kind of a general question, there are still somethings that confuse me about some actionscripting syntax. i’ve never been able to get a simple reason for syntax besides “JUST BECAUSE”
FIRST off this:
Width=30;
this._x = (this._x < 0) ? Width : (this._x > Width) ? 0 : this._x;
i understand this is using the tertiary operator, but i can’t wrap my finger around what it’s doing. is it kind of an if - else if - else?
SECOND:
myClip.onEnterFrame=function(){goRight(1,3);}
why does it look like this? is this the same as writing it like this
myClip.onEnterFrame=function(){
goRight(1,3);
}
THIRD: i almost always seem to have trouble with [ ]'s i know they work similar to the eval function used to but when i’m using them to call dynamic clips i always have to put this[] in front of them or the target, i can’t just start out with [“myclip” add i]._y instead this[“myclip” add i]._y
also with don’t you put a dot after this?

if anyone has any insights i would be most thankful

statement ? do if true : do if false

?: works as an if/else statement. If the statement is true, do the first thing, else if it is false, do the second thing. You MUST use it as in if/else though. You cannot just do…

statement ? do if true;

If you only have one thing and choose to use the operator you can use

statement ? do if true : null;

Second: Personal preference. I find it clearer to read when it isn’t on 1 line, but then again sometimes I do right things in one line. It works the same either way.

Third: [] signifies an array. You can use it as an actual array (via storing your own data) or you can use it to target an object on a timeline. Flash stores all the objects of each individual timeline in it’s own array so it can be called on late the way you said. In that case you need to first signify the timeline you are checking before you check the array for the object it contains :wink:

You don’t put a dot after it because you are checking an item within the timelines array.

I hope this info helps.

thanks
wait a second. so if flash is making its own arrays is there any way to call that array, and get it to return all the objects?
and speaking of returning is there a way to return multiple values from a function if i wanted to create a function that returned two values so that i could put them into a function?
example:
function returnVals(val1, val2){
newval1=val1 + 3;
newval2=val2 + 3;
newval3=val1 + val2;
return(newval1 add ", " add newval2 add ", " add newval3)
}
function traceVals(nval1, nval2, nval3){
trace(nval1);
trace(nval2);
trace(nval3);
trace(“done”);
}

traceVals(returnVals(2,4));

something like that

I didn’t test it, but something like this should let you check the objects in the current timeline (the timeline the script is on)…

[AS]var i;
for (i in this) {
if (this* instanceof Object) {
trace(i);
}
}[/AS]

As for using return to return 2 values… umm… I don’t think you can. I think the return can only return 1 value, but I don’t know. I don’t usually use return :-\