<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Styling a Button control</title>
	<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Tue, 06 Jan 2009 11:04:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Declan</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3026</link>
		<author>Declan</author>
		<pubDate>Fri, 28 Sep 2007 16:10:07 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3026</guid>
		<description>Thanks Peter. The ToggleButtonBar is a handy option alright. I'll persevere with the button control though, as it is still the preferred option for my current project and i will definitely want it again for future projects.

~ d :-)</description>
		<content:encoded><![CDATA[<p>Thanks Peter. The ToggleButtonBar is a handy option alright. I&#8217;ll persevere with the button control though, as it is still the preferred option for my current project and i will definitely want it again for future projects.</p>
<p>~ d :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3023</link>
		<author>peterd</author>
		<pubDate>Fri, 28 Sep 2007 14:50:32 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3023</guid>
		<description>Declan,

Perhaps not exactly what you want, but have you considered using the ToggleButtonBar control?

I have an example of it at &lt;a href="http://blog.flexexamples.com/2007/08/22/creating-a-vertical-togglebuttonbar-in-flex/" rel="nofollow"&gt;"Creating a vertical ToggleButtonBar in Flex"&lt;/a&gt;.

You can definitely do what you want with a regular Button control also. Either set the &lt;code&gt;toggle&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt; (and possibly the &lt;code&gt;selected&lt;/code&gt; property as well). But you'd have to track which button is currently selected and set the other button's &lt;code&gt;selected&lt;/code&gt; property to &lt;code&gt;false&lt;/code&gt;. Plus, you may need to override the &lt;code&gt;selectedUpSkin&lt;/code&gt; style (and maybe the &lt;code&gt;selectedOverSkin&lt;/code&gt; and &lt;code&gt;selectedDownSkin&lt;/code&gt; styles as well).

Hope that helps,
Peter</description>
		<content:encoded><![CDATA[<p>Declan,</p>
<p>Perhaps not exactly what you want, but have you considered using the ToggleButtonBar control?</p>
<p>I have an example of it at <a href="http://blog.flexexamples.com/2007/08/22/creating-a-vertical-togglebuttonbar-in-flex/" rel="nofollow">&#8220;Creating a vertical ToggleButtonBar in Flex&#8221;</a>.</p>
<p>You can definitely do what you want with a regular Button control also. Either set the <code>toggle</code> property to <code>true</code> (and possibly the <code>selected</code> property as well). But you&#8217;d have to track which button is currently selected and set the other button&#8217;s <code>selected</code> property to <code>false</code>. Plus, you may need to override the <code>selectedUpSkin</code> style (and maybe the <code>selectedOverSkin</code> and <code>selectedDownSkin</code> styles as well).</p>
<p>Hope that helps,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Declan</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3015</link>
		<author>Declan</author>
		<pubDate>Fri, 28 Sep 2007 11:07:40 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3015</guid>
		<description>toggle="true" is what's missing from the message above.

I typed the actual mxml tag but it didn't print out for some reason.</description>
		<content:encoded><![CDATA[<p>toggle=&#8221;true&#8221; is what&#8217;s missing from the message above.</p>
<p>I typed the actual mxml tag but it didn&#8217;t print out for some reason.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Declan</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3014</link>
		<author>Declan</author>
		<pubDate>Fri, 28 Sep 2007 11:04:01 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3014</guid>
		<description>I guess in this scenario:  is more appropriate for my needs but, i presume i would also need some actionscript to tell it to switch to false when the next button is clicked. Then a style can be applied to change the background of the toggle state from default grey to that bright lozenge effect.

sorry, i'm relatively new to this Flex stuff :-&#124;</description>
		<content:encoded><![CDATA[<p>I guess in this scenario:  is more appropriate for my needs but, i presume i would also need some actionscript to tell it to switch to false when the next button is clicked. Then a style can be applied to change the background of the toggle state from default grey to that bright lozenge effect.</p>
<p>sorry, i&#8217;m relatively new to this Flex stuff :-|</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Declan</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3012</link>
		<author>Declan</author>
		<pubDate>Fri, 28 Sep 2007 10:42:53 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-3012</guid>
		<description>Hmm... not quite what i had in mind. Nice to know though!

You know when you click say, a haloGreen button and it changes to a bright green Lozenge type effect? 

I would like that to stay that way until you click the next button. Kinda like switching the button on/off and when you click the next button it switches on and the previous one goes off.

hope that makes sense? ~ d</description>
		<content:encoded><![CDATA[<p>Hmm&#8230; not quite what i had in mind. Nice to know though!</p>
<p>You know when you click say, a haloGreen button and it changes to a bright green Lozenge type effect? </p>
<p>I would like that to stay that way until you click the next button. Kinda like switching the button on/off and when you click the next button it switches on and the previous one goes off.</p>
<p>hope that makes sense? ~ d</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-2982</link>
		<author>peterd</author>
		<pubDate>Thu, 27 Sep 2007 17:30:06 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-2982</guid>
		<description>Declan,

How about the following:

&lt;pre class="code"&gt;
&#60;mx:Button emphasized="true" /&#62;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>Declan,</p>
<p>How about the following:</p>
<pre class="code">
&lt;mx:Button emphasized="true" /&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Declan</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-2975</link>
		<author>Declan</author>
		<pubDate>Thu, 27 Sep 2007 15:09:17 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-2975</guid>
		<description>Hi Peter,

I have 3 buttons and when each one is clicked i would like them each to have a selected state or On effect so, the user will know what section they are in. Currently i am using haloBlue on each button and ideally i would like the haloBlue mouseOver state to stay when each button is selected.

Is that achievable and if so could you possibly show an example. Thanks! :-)</description>
		<content:encoded><![CDATA[<p>Hi Peter,</p>
<p>I have 3 buttons and when each one is clicked i would like them each to have a selected state or On effect so, the user will know what section they are in. Currently i am using haloBlue on each button and ideally i would like the haloBlue mouseOver state to stay when each button is selected.</p>
<p>Is that achievable and if so could you possibly show an example. Thanks! :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reza.H</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1603</link>
		<author>Reza.H</author>
		<pubDate>Sun, 09 Sep 2007 16:31:57 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1603</guid>
		<description>Thanks for your quick comment back :D</description>
		<content:encoded><![CDATA[<p>Thanks for your quick comment back :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1600</link>
		<author>peterd</author>
		<pubDate>Sun, 09 Sep 2007 15:04:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1600</guid>
		<description>Reza.H,

Try something similar to the following:

&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&#62;

    &#60;mx:Style&#62;
        .MyButton {
            borderColor: red;
        }
    &#60;/mx:Style&#62;

    &#60;mx:Script&#62;
        &#60;![CDATA[
            private function changeBorderColor(value:Object):void {
                var cssDecl:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".MyButton");
                if (cssDecl != null) {
                    cssDecl.setStyle("borderColor", value);
                }
            }
        ]]&#62;
    &#60;/mx:Script&#62;

    &#60;mx:Button id="button3"
            label="Button 3"
            styleName="MyButton"
            click="changeBorderColor('haloOrange');" /&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

You should be able to pass strings such as "red" or "haloBlue" to the &lt;code&gt;changeBorderColor()&lt;/code&gt; method, as well as color values such as 0xFF0000.

Hope that helps,
Peter</description>
		<content:encoded><![CDATA[<p>Reza.H,</p>
<p>Try something similar to the following:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        .MyButton {
            borderColor: red;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function changeBorderColor(value:Object):void {
                var cssDecl:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".MyButton");
                if (cssDecl != null) {
                    cssDecl.setStyle("borderColor", value);
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Button id="button3"
            label="Button 3"
            styleName="MyButton"
            click="changeBorderColor('haloOrange');" /&gt;

&lt;/mx:Application&gt;
</pre>
<p>You should be able to pass strings such as &#8220;red&#8221; or &#8220;haloBlue&#8221; to the <code>changeBorderColor()</code> method, as well as color values such as 0xFF0000.</p>
<p>Hope that helps,<br />
Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reza.H</title>
		<link>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1595</link>
		<author>Reza.H</author>
		<pubDate>Sun, 09 Sep 2007 14:44:43 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/09/styling-a-button-control/#comment-1595</guid>
		<description>Thanks:)

in this code:

&lt;pre class="code"&gt;
.MyButton {
    borderColor: red;
}
&lt;/pre&gt;

How do i  change declared Object Css on runtime or with  script?</description>
		<content:encoded><![CDATA[<p>Thanks:)</p>
<p>in this code:</p>
<pre class="code">
.MyButton {
    borderColor: red;
}
</pre>
<p>How do i  change declared Object Css on runtime or with  script?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
