>> I am new to Flex and Actionscript, and
only started
>> prototyping for our new project (a UI application on a J2EE
>> server) a week ago. It's been a fun learning this technology
>> and the Cairngorm framework does present a very neat
>> framework that suits our purpose well.
>
>Good to hear Cairngorm is working for you...
>
>> 1. I have a button whose face is completely occupied by a
>> .gif image. When the button is disabled, it is expected that
>> the image will be grayed out in addition to having a flat
>> appearance. Do I need to swap the image file references
>> whenever the image is enabled/disabled, or is there a better
>> way of achieving the same effect in Flex?
>
>We've used something like this in previous projects, with 4
>different PNG files for the different button skins:
>
><mx:Button xmlns:mx="http://www.macromedia.com/2003/mxml"
> falseUpSkin="@Embed('images/button_default.png')"
> falseDownSkin="@Embed('images/button_down.png')"
> falseOverSkin="@Embed('images/button_hover.png')"
> falseDisabledSkin="@Embed('images/button_disabled.png')"
> color="white"
> disabledColor="white"/>
>
>We would typically save that as a superclass, eg
>MyButton.mxml and then just use <namespace:MyButton /> instead
>of <mx:Button> when we want one of our skinned buttons.
>
>> prototyping for our new project (a UI application on a J2EE
>> server) a week ago. It's been a fun learning this technology
>> and the Cairngorm framework does present a very neat
>> framework that suits our purpose well.
>
>Good to hear Cairngorm is working for you...
>
>> 1. I have a button whose face is completely occupied by a
>> .gif image. When the button is disabled, it is expected that
>> the image will be grayed out in addition to having a flat
>> appearance. Do I need to swap the image file references
>> whenever the image is enabled/disabled, or is there a better
>> way of achieving the same effect in Flex?
>
>We've used something like this in previous projects, with 4
>different PNG files for the different button skins:
>
><mx:Button xmlns:mx="http://www.macromedia.com/2003/mxml"
> falseUpSkin="@Embed('images/button_default.png')"
> falseDownSkin="@Embed('images/button_down.png')"
> falseOverSkin="@Embed('images/button_hover.png')"
> falseDisabledSkin="@Embed('images/button_disabled.png')"
> color="white"
> disabledColor="white"/>
>
>We would typically save that as a superclass, eg
>MyButton.mxml and then just use <namespace:MyButton /> instead
>of <mx:Button> when we want one of our skinned buttons.
>
Why
not just manipulate the alpha channel?
Here
is an example that looks somewhat like what we use:
<mx:Script>
private function doGainFocus(target) {
var fade:Fade = new Fade(target);
fade.alphaFrom = 40;
fade.alphaTo = 100;
fade.duration = 200;
fade.playEffect();
}
var fade:Fade = new Fade(target);
fade.alphaFrom = 40;
fade.alphaTo = 100;
fade.duration = 200;
fade.playEffect();
}
private function doLoseFocus(target) {
var fade:Fade = new Fade(target);
fade.alphaFrom = 100;
fade.alphaTo = 40;
fade.duration = 200;
fade.playEffect();
}
</mx:Script>
var fade:Fade = new Fade(target);
fade.alphaFrom = 100;
fade.alphaTo = 40;
fade.duration = 200;
fade.playEffect();
}
</mx:Script>
<mx:Link id="searchImage"
icon="@Embed('http://www.zones.com/images/sid/SearchGlass.png')" alpha="40"
click="clickSearch()" toolTip="Search" mouseOver="doGainFocus(event.target)"
mouseOut="doLoseFocus(event.target)"/>
Of
course ours is using a Link instead of a Button and here we are just making the
image appear faded out while the fouse is not over the link (other code
elsewhere will focus the image if a certain search box is visible), but it
should be the same general idea. Now this might
not give a flattened appearance, but it should make the image appear greyed
out.
We are
also doing a fancy bit with the Fade Effect which I don't think is requried
so you could just replace the effect with something like 'target.alpha=40' or
'target.alpha=100'
--
Ronald Kinion
253-205-3000
x5162
[EMAIL PROTECTED]

