|
-
No worries, all good.
BTW, as an aside, there is a legitimate OOP example where ...(rest) is not only a workaround, but also the only way to achieve it in Flash (as far as I know - I'm happy to be educated).
Supposing you have multiple argument lists that you want to use for the same function. EG: A calculation that can either take [Point(),width,height], [x1,y1,x2,y2] or [MyShape()] as arguments but always does basically the same calculation.
You _could_ have multiple different functions ("myFuncXYWH()", "myFuncMyShape()", "myFuncPWH()") but imagine how unreadable and unmaintainable your code would then be (see also http://www.thc.org/root/phun/unmaintain.html for a laugh).
In Java (or similar), you can overload the function definitions with different argument signatures, but in AS3.0, there is no way to achieve this without ...(rest).
code:
private function myFunc(...(args)):Object {
var xin:Number;
var yin:Number;
var w:Number;
var h:Number;
if(args[0] is Point)) {
// assign vars
} else if(args[0] is MyShape)) {
// assign vars
} else {
// assign vars
}
return {tlc:new Point(xin,yin), brc:new Point(xin+w,yin+h), area:w*h};
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|