Actionscript 3 AS3-隐藏TileList';背景
我正在使用tileList和自定义ImageCell类,我想将灰色背景隐藏在我的M15和M19按钮后面。我尝试在ImageCell类和TileList上设置background.alpha和opaqueBackground,但没有成功 任何帮助都将不胜感激 edit2:添加tilelist设置和整个自定义单元格渲染器以提高清晰度Actionscript 3 AS3-隐藏TileList';背景,actionscript-3,flash,flash-builder,flash-cs6,Actionscript 3,Flash,Flash Builder,Flash Cs6,我正在使用tileList和自定义ImageCell类,我想将灰色背景隐藏在我的M15和M19按钮后面。我尝试在ImageCell类和TileList上设置background.alpha和opaqueBackground,但没有成功 任何帮助都将不胜感激 edit2:添加tilelist设置和整个自定义单元格渲染器以提高清晰度 //TileList Settings in main class tilelist.width = 235.53; tilelist.height = 592; ti
//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;
}
}
}
对于Flex:
list.setStyle("contentBackgroundAlpha", 0)
或者,如果应用程序对性能至关重要,则构建自定义外观
对于Flash Pro:
双击stage上的列表以更改当前外观,或创建新外观并使用
list.setStyle("skin", SkinName) //SkinName is a MovieClip in the library
我建议抓取flex spy并将其放入您的项目中(只需在SWC中复制,我相信这是一行)。这将有助于您精确定位绘制灰色背景的图形元素(其工作原理类似于Chrome的inspect)。我似乎无法让flexspy很好地处理AS3。。。Flash Builder发现它很好,但当我去编译它时却找不到它。如果你不能让它工作或找到答案,我建议发布一个新问题。也就是说,如果有时FB中出现内部错误,并且它正在悄无声息地失败,请尝试清理构建项目,并尝试重新启动FB。我确信,以这种方式进行设置是可行的,因为我14分钟前就做了:)尝试构建自定义皮肤并简单地删除了完整的背景?要删除单元格的背景还是列表的背景?是和否。通常每个单元格中都有背景。但是列表中还有一个额外的背景。因此,出于好奇,请尝试list.setStyle(“contentBackgroundColor”,0xff0000)并查看发生了什么,然后双击正在使用的平铺列表并更改当前外观。因为显然,没有办法通过代码更改样式。至少没有“干净”的方法。所以,只需编辑皮肤的电影唇。最简单的方法。位于库中的“组件资源”文件夹中