Hello,
I am modernizing an AS3 game and have stumbled upon an issue with placing multiple SimpleButtons in a MovieClip class. The intention here is to create a dialog box with 3 different options.
button1 = new SimpleButton(upState);
button1.x = 245.05;
button1.y = 149.3;
this.addChild(button1);
button2 = new SimpleButton(upState);
button2.x = 140.2;
button2.y = 149.3;
this.addChild(button2);
button3 = new SimpleButton(upState);
button3.x = 35.35;
button3.y = 149.3;
this.addChild(button3);
For some reason, the creation of another button makes the previous button move to it’s position when the three should all be separated. You can’t tell from here, but the buttons are slightly transparent. I know all three are being rendered on top of each other as the border is darker than it should be.
If I remove button3
's x and y declarations to default to (0, 0), button1
and button2
also shift there. I have also hidden button1
and button3
here for comparison. (The MovieClip is held within another.)
button1 = new SimpleButton(upState);
button1.x = 245.05;
button1.y = 149.3;
this.addChild(button1);
button1.visible = false;
button2 = new SimpleButton(upState);
button2.x = 140.2;
button2.y = 149.3;
this.addChild(button2);
button3 = new SimpleButton(upState);
this.addChild(button3);
button3.visible = false;
Additional details that might help: I am using the latest version of OpenFL and Lime. I am exporting to HTML5. The button states are .SVGs loaded into Shapes. I am using a GlowFilter on them. I originally removed this.addChild(button3)
in the last snippet, it completely removed the other buttons.
Edit: I’ve temporarily fixed my problem by creating two identical yet separate states, but that seems like bad practice.