加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex中用图片做button

发布时间:2020-12-15 05:08:33 所属栏目:百科 来源:网络整理
导读:方法一:派生mx.controls.Button类 package com { ?import mx.controls.Button; ? ?public class ImageButton extends Button ?{ ??[Embed(source="assets/topmenubtn.png")] ??private var icon:Class; ??[Embed(source="assets/topmenubtndown.png")] ??pr

方法一:派生mx.controls.Button类

package com
{
?import mx.controls.Button;
?
?public class ImageButton extends Button
?{
??[Embed(source="assets/topmenubtn.png")]
??private var icon:Class;
??[Embed(source="assets/topmenubtndown.png")]
??private var overIcon:Class;
??[Embed(source="assets/topmenubtndown.png")]
??private var downIcon:Class;
??public function ImageButton()
??{
???super();
???this.label = "";
???this.width = 16;
???this.height = 16;
???this.setStyle("cornerRadius",8);
???this.setStyle("icon",icon);
???this.setStyle("downIcon",downIcon);
???this.setStyle("overIcon",overIcon);
???this.setStyle("upIcon",icon);
??}
?}
?
}

?

方法2:设置样式,这种方法更灵活

?<fx:Style >
??@namespace s "library://ns.adobe.com/flex/spark";
??@namespace mx "library://ns.adobe.com/flex/mx";
??.myCustomButton {
???overSkin:Embed(source="assets/topmenubtn.png");
???upSkin:Embed(source="assets/topmenubtn.png");
???downSkin:Embed(source="assets/topmenubtndown.png");
??}
?</fx:Style >

?

var te:mx.controls.Button= new mx.controls.Button();
?????te.width=128;
?????var residandname:Array=array[i].split("|");
?????te.label = residandname[1];
?????te.accessibilityDescription=residandname[0];
?????te.accessibilityShortcut=residandname[2];
?????te.addEventListener(MouseEvent.CLICK,handleClick);

????? te.styleName="myCustomButton";

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读