Overload ??
/**
* Copyright beinteractive ( http://wonderfl.net/user/beinteractive )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/weP1
*/
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class Overload extends Sprite
{
public function Overload()
{
_field = new TextField();
_field.autoSize = TextFieldAutoSize.LEFT;
_field.defaultTextFormat = new TextFormat('Verdana', 10, 0x000000);
addChild(_field);
// Overload!?
test('Hoge', 'Fuga');
test(4, 1);
}
public static var _field:TextField;
privte function test(s1:String, s2:String):void
{
_field.appendText('String: ' + s1 + ', ' + s2 + '\n');
}
priate function test(n1:Number, n2:Number):void
{
_field.appendText('Number: ' + n1 + ', ' + n2 + '\n');
}
}
}
internal namespace privte;
internal namespace priate;
internal function test(...args):void
{
var prefix:String = '';
if (args[0] is String) {
prefix = 'String: ';
}
else {
prefix = 'Number: ';
}
Overload._field.appendText(prefix + args.join(', ') + '\n');
}