View difference between Paste ID: AiNNXxzN and EKKEx2Nk
SHOW: | | - or go back to the newest paste.
1
var arr = [new Btn(), new Btn(), new Btn()];
2
PlaceTools.distribute(arr, 20, PlaceTools.HORIZONTAL);
3-
class MyButton extends flash.display.Sprite{public function new() super()}
3+
	/*
4
	./Main.hx:13: characters 24-25 : Array<Btn> should be Array<Xywh>
5
	//Main.hx:13: characters 24-25 : Type parameters are invariant
6
	./Main.hx:13: characters 24-25 : Btn should be Xywh
7-
class Main extends flash.display.Sprite
7+
	./Main.hx:13: characters 24-25 : Btn should be { y : Float, x : Float, width : Float, height : Float }
8-
{
8+
	./Main.hx:13: characters 24-25 : For function argument 'arr'
9-
	public function new()
9+
	*/
10-
	{
10+
				
11-
		super();
11+
[new Btn(), new Btn(), new Btn()].distribute(20, PlaceTools.HORIZONTAL);
12-
		[new MyButton(), new MyButton(), new MyButton()].distribute(20, PlaceTools.HORIZONTAL);
12+
	/*
13-
	}
13+
	./Main.hx:24: characters 2-46 : Array<Btn> has no field distribute
14-
	
14+
	*/
15-
	public static function main()
15+
		
16-
	{
16+
PlaceTools.distribute([new Btn(), new Btn(), new Btn()], 20, PlaceTools.HORIZONTAL);
17-
		flash.Lib.current.addChild(new Main());
17+
	/*
18-
	}
18+
	Compiles and runs.
19-
}
19+
	*/
20
21
typedef Xywh = {x:Float, y:Float, width:Float, height:Float};
22-
class PlaceTools
22+
class Btn extends flash.display.Sprite{public function new() super()}
23-
{
23+
24-
	public static var HORIZONTAL:String = "horizontal";
24+
25
//------------------------------
26-
	public static function rightOf(target:Xywh, ref:Xywh, ?padding:Int=0, ?align:Bool=true, ?width:Float=0, ?height:Float=0):Void
26+
public static function distribute(arr:Array<Xywh>, ?padding:Int=0, ?dtype:String="horizontal")
27-
	{
27+
{