I am creating a Label in a Datagrid itemRenderer(extended from UIComponent) and right now I am setting the width of the label to some static value. I would like to create the label with 100% width. I do not want to use unScaledWidth because I am using link for the label so the link will be visible in the entire cell.
Thanks for the help in advance.
Am I missing something here or you should simply use percentWidth?
Using percentWidth won't work. If you have only a Label in the ItemRenderer, make sure the Label has (if an mx item renderer) autolayout="true" (which is the default) and add top="0" left="0" right="0" bottom="0" to the Label. This will make your label take up the entire cell.
If you are using a Spark item renderer, the default layout of none is absolute layout, and simply adding top="0" left="0" right="0" bottom="0" to the Label should be enough.
On another note, updateDisplayList() and measure() are two of the most overused overrides in Flex. Always try to fix your problem with an MXML skin-class before you try to go the route of overriding updateDisplayList() and measure(). Most MX class drawing methods were implemented incorrectly with private methods doing most of the drawing and this makes extending those classes difficult.
Related
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.
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.
How do I set the individual button sizes in a Spark ButtonBar? It used to be something like:
<mx:ButtonBar id="myButtonBar" buttonHeight="12" buttonWidth="250" >
I get an error when I try to do the same in Spark:
Cannot resolve attribute 'buttonHeight' for component type spark.components.ButtonBar
I don't want to create a separate skin...just something that will work inline if possible
Just set its layout.
<s:ButtonBar id="myButtonBar">
<s:layout>
<s:HorizontalLayout variableColumnWidth="false" gap="0" columnWidth="250"/>
</s:layout>
</s:ButtonBar>
Many things are just different in Spark :)
I see two different ways to approach this.
Create a custom skin class and set the Button Width that way. You'll have to review the existing ButtonBar Skin to figure out specifics.
Extend the button class to set he new button width and use that class to create new factories for the button related skin parts
You could also roll back to the Flex 3 ButtonBar and use the buttonWidth style. Some things are just easier in Halo.
Is it possible to dynamically (not in the project's options) change the dimensions of the stage by using ActionScript 3?
I'd want to create a 400x300px loader, but I also want it to load animations that have bigger or smaller dimensions. I would then change the width and height of the loader to make the loaded animations fit well.
Is there any way to do that?
Thanks.
<YourLoaderOrContainerWithAnimation top="0" bottom="0" left="0" right="0" width="100%" height="100%" minWidth="400" minHeight="300" maxWidth="400" maxHeight="300"/>
first of all use code.google.com/p/swfobject instead of embed tag, and yes you can directly change sizes like this.width=width_from_js; but as I remember swfobject will allow you to do this in raw js, just check it and let us know. :) thanks