I’ve been trying to understand the difference between scale9Grid when targetting html5 and flash as of lately. I’ve been trying to port a AS3/Flash project over to Html5 and have had a great deal of functional success - but there are some issues that we’ve found in particular scale9Grid doesn’t seem to work the same.
I created a demo project which draws a rounded corner box filled with a repeating bitmap fill and then a rect drawn over it to indicate the scale9Grid rectangle. It created a series of boxes with each scale9Grid rectangle stepping inward.
The image was produced with the following code - it creates a 70x70 square and stretches it to 300x70:
package ;
import openfl.display.Sprite;
import openfl.geom.Rectangle;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.utils.Assets;
class MoUITests extends Sprite {
var rpatt:BitmapData;
public function new () {
super();
var rwidth = 70;
this.rpatt = Assets.getBitmapData ("assets/repeating.jpg");
for (i in 1...8) {
var border = i*2;
var dbox = createDummyBox( 2,
rwidth,
new Rectangle( border,
border,
rwidth - (border*2),
rwidth - (border*2))
);
this.addChild(dbox);
dbox.y = (i*rwidth) + (i * 5);
dbox.width = 300;
}
}
function createDummyBox(border:Int, rwidth:Int, cutgrid:Rectangle):Sprite {
var dummy = new Sprite();
var matrix = new openfl.geom.Matrix();
matrix.scale(0.1,0.1);
var g = dummy.graphics;
//g.beginFill(0xFF,0.5);
g.beginBitmapFill(this.rpatt, matrix, true);
g.lineStyle(border,0);
g.drawRoundRect(0,0,rwidth,rwidth,10,10);
g.endFill();
g.lineStyle(1,0,1);
g.drawRect( cutgrid.x,
cutgrid.y,
cutgrid.width,
cutgrid.height);
trace(cutgrid);
dummy.scale9Grid = cutgrid;
return dummy;
}
}
What’s curious and confusing to me is in the html5 image you’ll notice that the left hand border blurs both the box border and the scale9grid rect border. It reduces the left hand border smudging by the 4th row - which it shouldn’t be smudging at all because the scale9grid rect should always be encompassing the the outside border.
Any ideas would be appreciated - I’ll be returning to this thread as a I expand my test and exploration.