Change Flex Button Icon Alpha using skin - actionscript-3

I have a custom skin for spark buttons.
I need to control the alpha of the image i set as the button icon using the skin. i.e. I need the image to change its opacity with change in the button states.
Is there a workaround, using the skin class, rather than writing event handlers??

When you create new button skin, you can see generated mxml markup there that sets different gradients for rects depending on states.
So, you can just set alpha values for different states in your image like
<s:Image alpha.disabled="0.1" alpha.over="0.4" /> and so on.
Update:
Now I understand your problem. Icon( which is set by icon property) is defined and managed by code in spark.skins.SparkButtonSkin, and your generated skin will extend that class.
Id of control that renders icon is iconDisplay of type BitmapImage.
So, you can change its behavior by adding following code to your generated skin:
<s:BitmapImage id="iconDisplay"
alpha.down="0.5"
alpha.over="0.7"
alpha.up="0"
/>
It will not add another icon.

Related

How to make the RubberBandXyZoomModifier fill with transparent color SciChart WPF

Using SciChart RubberBandXyZoomModifier, how can I make it fill the selection area box with a transparent grey color?
According to the SciChart docs, there are three ways to change the selection area box color for the RubberBandXyZoomModifier.
1/ Set the RubberBandXyZoomModifier.RubberBandFill, RubberBandStroke properties
<s:RubberBandXyZoomModifier RubberBandFill="#33FFFFFF" RubberBandStroke="#FF3333"/>
2/ Set the above properties in a custom theme
see Creating a Custom Theme
3/ overring a color of the above properties in an existing theme
see Overriding colors of our themes
Any of the above will achieve the desired result.

how to make a triangle button in flex using custom component?

I need a button that has a triangle shape.
how to make a custom component like a triangle button in flex?
what class should i override? updateDisplayList()? or layoutChrom()?
Depending on how complex you want the button to be you might be able to get away with using a process like this - except make the color outside the triangle the same for the 'clicked' and 'unclicked' states. Only change the color inside the triangle for the selected state.
If you need something more complex you can start with this or this for guidance.

Is there a possibility to increase font size of the spark label truncation tip in Flex 4?

I use Spark Label (Flex 4.6 SDK) in my project to show some text on a form and in case when the text does not fit in one line a truncation tip is shown (using maxDisplayedLines="1" and showTruncationTip="true" properties). But the font size in the tip is very small and I want to increase it but actually I have no idea how to do this.
OK so this is doable but not so easy to see how at first.
showTruncationTip tells the label to create a toolTip if isTruncated is true when you mouse over it. So with this knowledge, we can listen for the events that get fired regarding the tooltip being created and do some replacing or stylizing of the toolTip.
private var myTip:IToolTip;
// somewhere in your code
label.addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, createCustomTip);
private function createCustomTip(event:ToolTipEvent):void {
myTip = event.toolTip;
// do stuff to the existing toolTip or replace it with a custom one
}
There is full docs on how to create and replace custom tool tips here Creating Custom Tool Tips
There's a much simpler answer. See this link
http://blog.flexexamples.com/2008/05/22/changing-the-background-color-of-an-error-tip-in-flex/
and observe how they use <mx:Style> tags to modify the default CSS properties for .errorTip.

Corner Radius for Hover Rectangle

How can I set something like corner radius for the default rectangle which appears when an item is hovered?
Your question is a bit non-specific, which is why people are down voting you.
If you're talking about a Flex Button; the rounded corners on roll-over are part of an FXG asset; which is not changed by use of the cornerRadius style. At least in the mobile skin; I imagine the desktop skin is similar.
We put together a mobile skin that will create a square button; and something that should have been trivial took a few days. It's available as part of the Flextras Mobile Flex Components Package and usable for free.
Here is a sample we put together to show the button differences.
You can use in a non-mobile project at your own risk, though.
Trival in Flex3.
You did not specify what you are styling so this is how I would style a button
<mx:Style>
.roundedbtn{
cornerRadius: 10;
}
</mx:Style>
<mx:Button id='btn' styleName='mybtnnormal />
// or in ActionScript
btn.styleName = 'roundedbtn';
// or without the styles
<mx:Button cornerRadius="10" />

fancy tooltips in Swing

I have a JTable that I would like to display a fancy tooltip (basically a JTextArea) for particular cells in a column. I am using a custom cell renderer, so it would be easy if I could figure out how to popup a window when I hover over the cell renderer's component.
Are there any examples of how to do this?
You can use HTML in tooltips, if you use the <html> and </html> tags around the content.
Use HTML to format the tooltip. Using colored (<font>) and multi-line (<br>) tooltips is now easy.
Creating and overwriting the default JToolTip is a bit harder. Every component has a JToolTip instance and you can retrieve this one with JComponent.createToolTip(). To create a custom tooltip, extend the cell renderer and override it's createToolTip to implement your custom functionality (return a custom extended version of JToolTip).
I'm not sure I totally am clear on what sort of customizations specifically you're hoping to do, so I'll be general here.
There is a class, UIManager, that controls the look and feel of components, including the swing ToolTip class. The simple way to make an easy change is to call a method in UIManager to set properties for the tooltips. Doing this you could do things like use BorderFactory to add a decorative border, or change the background color, etc.
Here are some examples of changing some of these properties:
UIManager.put("ToolTip.background", new ColorUIResource(255, 247, 200)); // The color is #fff7c8.
Border border = BorderFactory.createLineBorder(new Color(76,79,83)); // The color is #4c4f53.
UIManager.put("ToolTip.border", border);
ToolTipManager.sharedInstance().setDismissDelay(15000);// 15 seconds
If you want to change a whole bunch of things about their look and feel, it is better to extend your current look and feel with a class implementing custom tooltip look and feel. A full example of this can be found in this blog post by a former Sun developer.
You might also have a look at this Stack Overflow question on how to set the insets on a tooltip.