Closed CrazyFlasher closed 6 years ago
This works as ugly workaround :)
private function setButtonStyles(button:Button):void
{
button.addEventListener(FeathersEventType.STATE_CHANGE, function ():void
{
if (button.currentState == ButtonState.DOWN)
{
button.pivotX = button.width / 2;
button.pivotY = button.height / 2;
button.scale = 1.2;
} else
{
button.scale = 1.0;
}
});
}
I'm afraid that I cannot reproduce this issue. I tried the following code, and the button's scale returned to 1.0 as expected.
var button:Button = new Button();
button.label = "Hello";
button.move(50, 50);
button.scaleWhenDown = 1.2;
this.addChild(button);
I think there are some extra conditions I need to investigate, because some buttons work fine. I'll investigate ASAP and provide more detailed info
This is weird, but I cannot reproduce it on my home machine...I'll investigate more
By the way, is there a simple way to animate scaling?
You can animate scaleX and scaleY with a regular Tween. However, that doesn't work exactly the same as scaleWhenDown. scaleWhenDown doesn't affect layouts, but scaleX and scaleY might.
This is really weird, but this happens with some textures from atlas: If I use other textures, it works fine. The code is simple:
private function setGuiScreenAddSilverStyles(button:Button):void
{
button.setScaleForState(ButtonState.DOWN, 1.2);
button.defaultSkin = ift.imageFromTexture(TexturesNames.GENERAL_ADD_COINS_BTN);
}
I've attached atlas. Texture name is General/add-coins-btn.png
ui.zip
I tried the following code, but I still cannot reproduce the issue.
[Embed(source="ui.png")]
private static const ATLAS_IMAGE:Class;
[Embed(source="ui.xml",mimeType="application/octet-stream")]
private static const ATLAS_XML:Class;
var atlas:TextureAtlas = new TextureAtlas(Texture.fromEmbeddedAsset(ATLAS_IMAGE), XML(new ATLAS_XML()));
var button:Button = new Button();
button.move(50, 50);
button.setScaleForState(ButtonState.DOWN, 1.2);
button.defaultSkin = new ImageSkin(atlas.getTexture("General/add-coins-btn.png"));
this.addChild(button);
I also tried with keepDownStateOnRollOut, and that is working correctly too.
Ok, I'll try to reproduce it in simple project and attach it here soon
OK, the issue was in skipUnchangedFrames
setted to true
:)
This is a good feature of Starling 2.
Need to think, how to keep this flag enabled.
Any suggestions?
I'm pretty sure that I had skipUnchangedFrames enabled when I was trying to reproduce this issue. However, this is a good clue. If I can figure out how to get the button to change state without modifying the display list, I may be able to reproduce it now.
Hi, I setted
button.scaleWhenDown = 1.2;
to button style, but after click it doesn't return back to normal scale: