Corner Radius for Hover Rectangle - actionscript-3

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" />

Related

Change Flex Button Icon Alpha using skin

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.

How to override titlewindow 4px padding in flex actionscript?

I am new to flex and i am trying to create a title window with no padding whatsoever on the sides. In the adobe documentation http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/containers/TitleWindow.html it says that the title window has a 4px padding. I was wondering if i could get rid of it by overriding the updateDisplayList function and set the padding to 0 (I have been trying this but I cant seem to find the right attribute to set). Basically what i want to do is to have a button on the bottom left corner of the title window and the edge of the button should be 0px from the border of the window.
PS: I only need to do this for title window. There is probably another way of doing it with a Panel or some other component which im not interested in.
The link to the TitleWindow docs has a styles section. It has styles for paddingTop, paddingBottom, paddingLeft, and paddingRight.
CSS styles are set a little differently in Actionscript versus MXML. Since css styles are not properties of the object, you have to use the setStyle() method in Actionscript. You can also use a style sheet.
MXML:
<mx:TitleWindow paddingLeft="0" paddingRight="0" />
Actionscript:
var tw:TitleWindow = new TitleWindow();
tw.setStyle("paddingLeft", 0);
tw.setStyle("paddingRight", 0);

Adobe air mobile - softKeyboardType is not working when using skinClass to allow scrolling?

I am trying to set the softKeyboardType to email but when ever i use skinClass="spark.skins.mobile.TextAreaSkin" it doesn't change it but when i take off skinClass="spark.skins.mobile.TextAreaSkin" it does work. The problem is i need the skinClass="spark.skins.mobile.TextAreaSkin" class to allow my application so scroll with out it the text does not stay with in the bounds of the text input boxes. Has anyone seen this problem or another fix the the scrolling problem?
Code examples
<s:TextInput softKeyboardType="email" id="id1" width="100%" skinClass="spark.skins.mobile.TextInputSkin" />
<s:TextArea softKeyboardType="email" id="id2" height="400" width="100%" skinClass="spark.skins.mobile.TextAreaSkin" />
Thank for the help,
Justin
I've checked mobiletheme default.css in flex 4.6 sdk
adobe is using different skins for TextInput and TextArea components
TextArea
{
...
skinClass: ClassReference("spark.skins.mobile.StageTextAreaSkin");
}
TextInput
{
...
skinClass: ClassReference("spark.skins.mobile.StageTextInputSkin");
}
so I think you should use StageTextAreaSkin or StageTextInputSkin as a skinClass for corresponding components
softKeyboardType will work in this case but text position problem will stay, I think you will need to change/fix StageTextAreaSkin or StageTextInputSkin sources for your scrolling
Confronted with this issue, I came up with a workaround which worked in my case.
Use default skin, set your softKeyboardType.
While doing layout for your screen, create a section which contains the uppermost part of your screen and which you can easily collaps or toggle its includeInLayout property, so when you do that, it will make your TextInput or TextArea to appear over the keyboard, bypassing the scroller for that purpose.
Then, when your field receives focus, in focusIn handler, you collaps or toggle this section. This does two good things: first, it lifts your field over the keyboard, and second, it removes focus from your field (at least in my case it did, not sure 100%, if it doesn't, then shift focus manually). This is good because when you set focus on your field once again (yourfield.setFocus()), the cursor will appear where you want it, within the bounds of your field.
Once done typing, you restore top section to its original state from focusOut or softKeyboardDeactivate handlers.
Hope this helps...
seems like it's flex 4.6 bug
http://forums.adobe.com/message/4122095

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.

creating a rounded button from AS3?

How to create rounded & good looking "OK" and "CANCEL" buttons from AS3 ?
I dont want to use any images for these, just draw them?
I'd use a Shape or a Sprite, and draw on it using the graphics proerty
something like
var s:Shape = new Shape();
s.graphics.beginFill(0x123123, 1);
s.graphics.drawRoundRect(...);
s.graphics.endFill();
or using a Sprite if you want to attach additional elements on it (like a label)
Further to monkee's answer, if using Flex you can create very simple rounded Buttons by setting the cornerRadius style.
There are many ways to do that.
If I were you - if a button is all you need. Make yourself a button class. If you need more Layout & GUI elements, consider using the Flex Framework or something like ASwing
In Flex either learn how to skin a component or do it yourself. Just create a canvas, box, label or whatever with a picture in it and make it behave like a button.