Untoggle a Flixel-UI toggle-button?
I'm using Flixel UI and creating buttons in a state with an xml. My problem is that I can't figure out how to untoggle a toggle button, so it behaves like the image below:
Figure nº4 is giving me trouble because i don't know how to call a toggle button with code and check its status (for instance
pressed == true), so i can untoggle all of the buttons that control speed. I've tried
_ui.getAsset("play");, but it just returns null.
Is there a solution to this, or its better to just use regular flixel buttons (not flixel-ui and not xml)?
I couldnt do it with xml so i had to switch to drawing the UI by code and make normal buttons, wich is kinda sad. Here's my solution:
//create a normal button, not a toggle button. pausebutton = new FlxUIButton(x, y); pausebutton.loadGraphicsMultiple(up.png, over.png, down.png]); pausebutton.params = ["parameter"]; add(pausebutton);
Then, when the button is pressed, switch the graphics for up and down:
//switch the graphics for the button pressed pausebutton.statusAnimations = ["pressed", "highlight", "normal"]; //untoggle the other buttons, in this case playbutton, and update it playbutton.statusAnimations = ["normal", "highlight", "pressed"]; playbutton.updateStatusAnimation();
That solves the issue.
I couldnt do it with xml so i had to switch to drawing the UI by code and make normal buttons, wich is kinda sad.
I think you can access elements created via XML in your code using
FlxUI.getAsset(key), which means you could continue using XML. :)