I'm new to flex,and I want to change the image of HSlider,like this
What should I do?please give me a simple example.
#RIAstar had a great answer. But there is a little problem - this orange part before thumb. AFAIK the easiest way to create skin like this is to add rect or more complicated figure in HSlider skin, that will change it's width according to thumb's x coordinate, i.e.
<s:Button id="track" left="0" right="0" top="0" bottom="0" minWidth="33" width="100"
tabEnabled="false"
skinClass="spark.skins.spark.HSliderTrackSkin" />
<s:Rect width="{thumb.x + thumb.width/2}" height="{track.height}">
<s:fill>
<s:SolidColor color="0x00FF00" />
</s:fill>
</s:Rect>
<s:Button id="thumb" top="0" bottom="0" width="11" height="11"
tabEnabled="false"
skinClass="spark.skins.spark.HSliderThumbSkin" />
You'll have to create a custom skin. Now, HSlider is a little bit special in that it has some subcomponents that are also skinnable. You'll actually have to create three custom skins:
one for the HSlider itself (this skin includes the tooltip)
one for the track (the yellow/brown zone in your picture)
and one for the thumb
The track and the thumb are both in fact Buttons so those skins will have to be Button skins.
Explaining the entire process will make this answer too lengthy and specific, so I'll just get you started. You should be able to figure it out from there. I'll also assume you're using FlashBuilder as an IDE.
Create main skin
Set the skinClass style on an HSlider and hit Alt+Space. This will bring up code completion, but you can also select "Create Skin...".
Select that and a wizard will appear. Fill out something like the following. Note that we're making a copy of the default Spark HSlider skin. We remove the styling code because it will not be necessary in such a customized skin.
Create track and thumb skins
Open this new skin class and scroll down to the bottom. You'll see two Buttons; one with id track and one with id thumb. Their skinClass style is set to the default spark skins for these buttons. Delete the content and repeat the operation of the previous step (creating a new skin), only this time create a copy of HSliderTrackSkin and HSliderThumbSkin
Edit the skins
You now have an exact copy of the default Spark skins for HSlider (except you removed the styling). Now you can start editing: changing colors, changing shapes, etc. If you need more information about Flex graphics, I suggest you Google up on FXG. But you can just try to fiddle with the default skins and see where you can get too.
Related
I have a custom skin applied to a Flex 4 spark datagrid. One really annoying issue I am having is finding the ability to override or change the selected row border color. I was able to set the selectionColor just fine but the border is still the default light blue color. I need it to be yellow.
Anyone know where I can find this style or override this border that is being set when selection happens within the skin itself.
thanks,
-Matthew
I believe it's the caretColor style. If not, you can do this:
Create a skin file for the spark datagrid based on spark.skins.spark.DataGridSkin
Now yous hould have a copy of the DataGrid skin, change the following code,
<s:stroke>
<!--- #private -->
<s:SolidColorStroke id="caretIndicatorFill" color="0x0167FF" weight="1"/>
</s:stroke>
Change 0x0167FF to the desired color..
A bit late, but FYI there is no need to edit the skin, there is a style caretColor on spark DataGrid:
<s:DataGrid caretColor="0xffffff" ...
Hope that helps
I am trying to use the spark.skins.spark.TitleWindowCloseButtonSkin in a custom component and make it look thematically similar to how it looks in TitleWindow. Just specifying it as the skin class for a Button works no problem. I also have a .css style applied to all my TitleWindow classes that affects the close buttons in a TitleWindow. If I set the chrome color of the TitleWindow in .css then the close button skin also gets colorized to match this color. My custom component is also using the same style reference as my TitleWindows. But the Button instance inside of my custom component does not get colorized. So while I have blue TitleWindows with blue-colorized closed buttons, I have a blue custom component with a default gray background closed button (on button-press, the gray background appears).
There must be something going on with TitleWindowSkin and TitleWindowCloseButtonSkin via the colorization mechanic but I don't understand what it is. How should I solve this problem? I need to make the close button style in my custom component match that of the close button in my TitleWindows.
Here is a picture of the problem:
The TitleWindow is on the left in both pictures. The custom component is on the right.
In the left frame, you see the TitleWindow close button in the down position, note that its down state is colorized to match the theme of the TitleWindowSkin. On the right you see the down state of the custom component's close button. I do not know how to colorize the default gray to match the blue theme applied to the custom component.
I am sure there are a multitude of ways to solve this. I am looking for the most "correct" way. I do not want to hard-code colors because later an actual designer will come in and tweak the .css.
PS My custom component extends from spark.components.Group. Could that be a problem???
I should also mention that normal Button instances that use the default spark ButtonSkin do seem to get styled properly in the custom component (part of the reason this problem is so frustrating).
EDIT: yes, yes indeed it looks like the first step to a solution is to inherit from SkinnableComponent not Group or UIComponent...
In your TitleWindowSkin you need to add "closeButton" in exclusions array at top, I have resolved the same issue with this.
hm, this is curious since I can't seem to find any reference to chrome color or anything within the close button skin:
<s:Rect left="0" top="0" right="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="0x000000"
alpha="0.0"
alpha.over="0.7"
alpha.down="0.7"
weight="1"/>
</s:stroke>
<s:fill>
<s:SolidColor color="0xCCCCCC" alpha="0" alpha.down="0.7" />
</s:fill>
</s:Rect>
If I were you, I'd just create a skin based on the close button skin and have a reference to a style color using getStyle which can be changed in the css.
Ok, so I have mostly figured out the problem. It stems from the fact that I am not using a proper skin technique on my custom component. The custom component logic is fine where it is at, but I need to prepare a separate skin class that actually instantiates the custom component's "parts" (ie: sub-components). Currently, the custom component does this in createChildren(). Furthermore, to take advantage of the colorization mechanic, the skin class must inherit from SparkSkin. The TitleWindowCloseButton instance needs to be a member of the custom component's skin class (as well as having a reference in the custom component class). SparkSkin will automatically color transform (colorize) every child of the custom component's skin unless it is explicitly excluded. Finally, back in the custom component, override partAdded() and when "closeButton" comes up, add the close button's event handler at that time. Feels very Cairngorm-ey... but I digress (must suppress urge to rant about the stoopid that are "helper" classes).
Newbie here,
I have a skinned button at x=47 y=126 which is later "covered" by a .png that loads dynamically. Once the .png loads, the button disappears. How can I tell Flash Builder 4 to place the .png behind the button so that it is always clickable. FYI: if I move the button away from the graphic, it works just fine, but, for design purposes, I really would like it to stay where it is.
Thanks,
Jason M.
You could also try giving the button a depth value of 1 or higher.
"Spark containers order their items based on their depth property, with the lowest depth in the back, and the higher in the front.Items with the same depth value appear in the order they are added to the container."
<s:Button x="47" y="126" depth="1" skin="customSkin"/>
Conversely you could add a smaller depth to the .png, or if you are drawing them in the same container change the order they are in there. (From the quote above on depth)
If you need to have an image as a background for your button you should place it behind button the following way:
<s:Group>
<s:BitmapImage />
<s:Button />
</s:Group>
I suppose your case is the following:
<s:Group>
<s:Button />
<s:BitmapImage />
</s:Group>
By default TitleWindows seem to have no padding. I tried the properties "left", "right" etc and it doesn't work. Actually I'd like to have a default for my whole app, so I tried creating a skin but no matter where in the skin I add 'left="50"' it just doesn't create padding on the left. You'd think that you should add it to the element with id="contentGroup", as described on this Adobe Skinning help page, but that does not work.
Surely this is something almost everyone wants to do?
The contentGroup in the default TitleWindowSkin is inside a VerticalLayout which does not respect top/left/right/bottom constraints.
You could do this by duplicating the default TitleWindowSkin and wrapping the contentGroup with a Group with width/height of 100%:
...
<s:Group width="100%" height="100%">
<!--- #copy spark.components.SkinnableContainer#contentGroup -->
<s:Group id="contentGroup" top="10" left="10" right="10" bottom="10" minWidth="0" minHeight="0" />
</s:Group>
...
Since the TitleWindow extends the Panel component, it doesn't support the padding properties a HGroup or VGroup based component would. As far as I know, there's no way to skin a TitleWindow so that the padding properties are automatically set.
All I do is set the x and y coordinates of my components within the TitleWindow so that they are laid out where I want them.
I have been doing much research on this - including creating a custom skin but cannot seem to be able to do it. I just want to have one border around both the checkbox and label. I also want a background color which I did manage to via opaqueBackground property (setting it via AS3). Just can't seem to find the key to have a border as well. Any help is appreciated. I need the same for radio buttons as well.
You're on the right track by creating a custom skin. Just copy the default CheckBoxSkin and add a Rect at the top level so it gets drawn first (below where the states are declared and before the first Group):
<s:Rect left="0" right="0" top="0" bottom="0">
<s:stroke>
<s:SolidColorStroke color="#ff0000"/>
</s:stroke>
</s:Rect>
Then set your new skin as the checkbox skin, either in CSS or directly on the specific checkbox via its skinClass.
Hope that helps.