Image of Skinning Buttons in Flex 4

I am trying to hide a button with images.

The following code is for flex 3, but I need the equivalent in flex 4 code. Do not use a skin class.

.muteVolumeButton 
{
  upSkin: Embed(source='images/sound-mute.gif');   
  overSkin:Embed(source='images/sound-hover.gif');   
  downSkin: Embed(source='images/sound-on.gif');   
  disabledSkin: Embed(source='images/sound-mute.gif');
}

Please post the flex 4 code.

+3
source share
2 answers

I have to say that skinning in the Spark infrastructure is slightly different from the Halo method.

The best description here . And this is the best and easiest way to solve your problem. Here is the code:

components.ImageButton.as

package components  
{  
 import spark.components.Button;  

 [Style(name="imageSkin",type="*")]  
 [Style(name="imageSkinDisabled",type="*")]  
 [Style(name="imageSkinDown",type="*")]  
 [Style(name="imageSkinOver",type="*")]  

 public class ImageButton extends Button  
 {  
  public function ImageButton()  
  {  
   super();  
  }  
 }  
}  

Script:

[Embed('assets/images/btnGoUp.png')]  
[Bindable]  
public var btnGo:Class;  

[Embed('assets/images/btnGoOver.png')]  
[Bindable]  
public var btnGoOver:Class;  

[Embed('assets/images/btnGoDisabled.png')]  
[Bindable]  
public var btnGoDisabled:Class;  

MXML Part:

<components:ImageButton buttonMode="true"  
   imageSkin="{btnGo}" imageSkinDisabled="{btnGoDisabled}"  
   imageSkinDown="{btnGoOver}" imageSkinOver="{btnGoOver}"  
   skinClass="assets.skins.ImageButtonSkin"/>  

In all other cases, you can always exchange states using CSS.

  • You should always put your skin on: @namespace s "library://ns.adobe.com/flex/spark";
  • : s|Button:down
  • , CSS, .

:

http://blog.flexexamples.com/2009/03/03/styling-an-emphasized-fxbutton-control-in-flex-gumbo/

http://blog.flexexamples.com/2010/03/24/using-a-bitmap-image-skin-in-a-spark-button-control-in-flex-4/

http://opensource.adobe.com/wiki/display/flexsdk/CSS+Namespaces+Support

http://cookbooks.adobe.com/post_How_to_use_the_new_CSS_syntax_in_Flex_4-15726.html

+8

script :

        [Embed(source="assets/images/button-up.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
        [Bindable]
        public var upImg:Class; 


        [Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
        [Bindable]
        public var overImg:Class;

        [Embed(source="assets/images/button-disabled-skin.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "2", scaleGridBottom = "3")]
        [Bindable]
        public var disabledImg:Class;

        [Embed(source="assets/images/button-over.png", scaleGridLeft = "4", scaleGridRight = "5", scaleGridTop = "4", scaleGridBottom = "5")]
        [Bindable]
        public var downImg:Class;

:

<s:BitmapImage source="{upImg}"
               source.over="{overImg}"
               source.down="{downImg}"
               source.disabled="{disabledImg}"
               width="100%"/>

'

+2

Source: https://habr.com/ru/post/1765303/


All Articles