Closed kolobok55 closed 8 years ago
positive value of width reseting negative value of scaleX.
In Starling, width
and height
are actually just wrappers for scaleX
and scaleY
. So when you double the width
of an object, its scaleX
will be 2.0
.
The same is happening here. Add a trace output to your code, like this:
var img1:Image = new Image(txtr);
img1.scale9Grid = new Rectangle( 8, 8, 16, 16 );
img1.x = 250;
img1.width = 200;
trace(img1.scaleX); // -> 6.25
img1.scale = 1;
As you can see, after setting the width
, the scaleX
is raised to 6.25
in your sample. Then, in the next line, you're changing it back to 1.0
— which means that the size change is undone.
Does that explain the behavior for you?
Older version hasn't this problem. I've solved this by wraping Image into Sprite. Sprite working correct. IMHO all subclasses of DisplayObjects must has same behavior, scale as factor must be independed of width and height property like a Sprite.
There must be a misunderstanding here, because this always worked like this in Starling. And even on a sprite, when you change its width
, scale
will change, as well.
var sprite:Sprite = new Sprite();
var quad:Quad = new Quad(100, 100);
sprite.addChild(quad);
trace(sprite.width); // 100
trace(sprite.scaleX); // 1.0
sprite.width = 200;
trace(sprite.width); // 200
trace(sprite.scaleX); // 2.0
sprite.scaleX = 1.0;
trace(sprite.width); // 100
trace(sprite.scaleX); // 1.0
Or do you mean something else? (Feather's Scale9Image
and Scale3Image
might have worked different, if you mean those.)
Sorry, you're right, i've used featherui Scale9Image, migration makes this mistake.
Okay, that explains it. Yes, the reason this works different than Feather's Scale9Image
is that — as you wrote yourself — objects should always behave the same way. And in this case: an image with a scale9Grid
must behave just the same way as an image without one.
Let me know if you run into anything else! :smile:
second Image hasn't 200х200 size