GiG
September 12, 2017, 2:15pm
#1
Hi,
I have found a problem/bug with custom shapes.
I have a Sprite and am drawing a button
switchBtn = new Sprite();
switchBtn.graphics.beginFill(0x000000, 0.7);
switchBtn.graphics.moveTo(0 , 0);
switchBtn.graphics.lineTo(45, 0);
switchBtn.graphics.curveTo(50, 0, 50, 5);
switchBtn.graphics.lineTo(50, 30);
switchBtn.graphics.lineStyle(1, 0xffffff);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);
switchBtn.graphics.endFill();
This is a button with a rounded angle and two marked white sides: if I apply MouseEvent listeners it behaves like it wasn’t there, events are not triggered, BUT … if I remove
switchBtn.graphics.lineStyle(1, 0xffffff);
it magically starts working, and all MouseEvents are triggered. This worked in AS3.
Have you tried separating the line and the fill? (I have no idea if this would help; it just seems like something to try.)
switchBtn = new Sprite();
switchBtn.graphics.beginFill(0x000000, 0.7);
switchBtn.graphics.moveTo(0 , 0);
switchBtn.graphics.lineTo(45, 0);
switchBtn.graphics.curveTo(50, 0, 50, 5);
switchBtn.graphics.lineTo(50, 30);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);
switchBtn.graphics.endFill();
switchBtn.graphics.lineStyle(1, 0xffffff);
switchBtn.graphics.moveTo(50, 30);
switchBtn.graphics.lineTo(0, 30);
switchBtn.graphics.lineTo(0, 0);
GiG
September 14, 2017, 7:42am
#3
Yes, that is what I did:
beginFill
-> shape
endFill
beginFill
-> lineStyle
-> line
endFill
This way it works, but it is a workaround.