02-22-2011 07:20 PM
Getting down to the wire!
Probably a simple question but I googled and searched forum and couldn't find out how to do this. I'm trying to set the colour of a LabelButton but can't seem to do it.
addButton.cacheAsBitmap = true;
addButton.opaqueBackground = 0x99CCFF;
But that only sets the colour behind the button and not the button.
Do I need to do skinning or using graphic drawing? I figured there must be an easy way to set button colour!
02-22-2011 07:33 PM
var enter_format : TextFormat = new TextFormat( null, 26, 0x2CB830, true ); this.keypad_enter.setTextFormatForState( enter_format, SkinStates.DOWN ); this.keypad_enter.setTextFormatForState( enter_format, SkinStates.SELECTED ); this.keypad_enter.setTextFormatForState( enter_format, SkinStates.UP );
02-22-2011 08:28 PM
I am able to change the colour of the text and font size, etc. which will be useful but I don't see how to set the background colour of the button. I probably didn't specify that in my original post.
I took your code and did the following. format.color is the text color and I didn't see an attribute for background color. Probably something to do with transparency?
var format : TextFormat = new TextFormat();
format.color = 0x2CB830;
format.size = 25;
format.bold = true;
addButton.setTextFormatForState( format, SkinStates.DOWN );
addButton.setTextFormatForState( format, SkinStates.SELECTED );
addButton.setTextFormatForState( format, SkinStates.UP );
02-22-2011 08:32 PM
to alter the look of a labelbutton and its background, you have to create a custom skin for it. to do that, here is a page from the Development Guide that shows you a step by step way:
hope that clears things up for ya. good luck!
02-22-2011 08:44 PM
Ah...thanks JRab. I wasn't going to delve into skinning until I got all the basic functionality of the app going but sometimes I get side-tracked and want to make the app prettier. Back to work on the functionality...
Thanks jtegen as well for your help - that will come in handy later on.
Both you guys are awesome and are a big help.
02-22-2011 10:36 PM
this is a follow up to your skinning question. I know you didnt ask for it but i had some free time and thought this would be an good add to the PlayBook Wiki Site. I wrote up a step by step (mostly) of how to create your own skin and included project files and PSD for it. hopefully it can help some people out that want to create their own custom button:
If you guys ever want to add something either send @willyyr a PM or me a PM and we'll upload it for you or he can create an account for you. Hopefully we will be able to build a big enough library for everyone to use. Good luck!
02-23-2011 01:23 AM
Nice write-up on skinning, JRab. I can see that being useful to create a more interesting looking app.
But if I just want to change the colour of a LabelButton, is there no easier way of doing that other than creating one's own button image .png?
I often want to highlight a button in a slightly different colour to call attention to it.
02-23-2011 01:26 AM
unfortunately all the skinning is done via embedded images. if you can find someway to alter the color there might be a way. ive seen things on colortransform that might help too. but not too sure. here is a link to a thread dealing with that here:
not too sure i havent dabbled in that just yet but sounds logically fitting. let me know how it works out. good luck!