1、设计思路
由于flex中没有设置linkbutton的背景色的属性,现在得从两个方面入手:第一,直接通过调用样式方法画出linkbutton的背景色;第二,设置linkbutton的背景图片。这里,讲述的是第一种方法
2、设计源码
<?xml version="1.0" encoding="utf-8"?>
<s:application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationcomplete="inithandler(event)">
<s:layout>
<s:basiclayout/>
</s:layout>
<fx:script>
<![cdata[
import mx.events.flexevent;
/**
* 初始化函数
*/
protected function inithandler(event:flexevent):void
{
mylinkbutton.graphics.beginfill(0x00ff00);
mylinkbutton.graphics.drawrect(0,0,mylinkbutton.width,mylinkbutton.height);
mylinkbutton.graphics.endfill();
}
]]>
</fx:script>
<fx:declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:declarations>
<mx:vbox width="100%">
<mx:linkbutton id="mylinkbutton" label="查询" x="100" y="100"/>
</mx:vbox>
</s:application>
3、设计结果

发表评论