我正在使用带有自定义 ImageCell 类的 tileList,我想隐藏 M15 和 M19 按钮后面的灰色背景。我尝试在 ImageCell 类和 TileList 上设置 background.alpha 和 opaqueBackground ,但没有成功...
任何帮助,将不胜感激。
edit2:为清楚起见,添加 tilelist 设置和整个自定义单元格渲染器...
//TileList Settings in main class
tilelist.width = 235.53;
tilelist.height = 592;
tilelist.move(14, 118);
tilelist.columnWidth = 220.53;
tilelist.rowHeight = 53;
tilelist.visible = true;
tilelist.direction = ScrollBarDirection.VERTICAL;
tilelist.setStyle("cellRenderer", UserListRenderer);
tilelist.setStyle("contentBackgroundAlpha", 0);
//Custom CellRenderer
package {
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ImageCell;
import fl.controls.TileList;
import flash.text.*;
public class UserListRenderer extends ImageCell implements ICellRenderer {
public function UserListRenderer() {
//inherit the variables from the parent
super();
//we don't want to stretch our images to fit the size of the box
loader.scaleContent = true;
//change the cursor as if this was a button
useHandCursor = true;
}
override public function set data(data:Object):void
{
super.data = data;
// Set the default skin to be invisible. This is a bit
// easier than creating a new skin, if your goal is
// to hide the white background.
this.setStyle("contentBackgroundAlpha", 0);
}
/**
* Now we override the function that draws the layout
* so we can move the image beside the text
**/
override protected function drawLayout():void
{
//adjust the icon for any existing padding
var imagePadding:Number = getStyleValue("imagePadding") as Number;
//offset the image in the box so it's not touching the top of it
loader.move(1, 0);
var h:Number = height-(imagePadding*2);*/
var w:Number = width + (imagePadding*2);
var h:Number = height + (imagePadding*2);
if (loader.width != w && loader.height != h) {
loader.setSize(w,h);
}
//re-draw the image
loader.drawNow();
//hide the original cellImage textField so we can display our new one later
textField.visible = false;
//adjust the background
background.width = width;
background.height = height;
}
}
}