Actionscript 3 在VBox上设置特定的角半径
默认情况下,如果在VBox上设置Actionscript 3 在VBox上设置特定的角半径,actionscript-3,apache-flex,flex3,Actionscript 3,Apache Flex,Flex3,默认情况下,如果在VBox上设置cornerRadius,则所有四个角都将生效。如何仅将cornerRadius应用于左下角和右下角?扩展VBox组件并覆盖updateDisplayList方法,如下所述:- override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWi
cornerRadius
,则所有四个角都将生效。如何仅将cornerRadius应用于左下角和右下角?扩展VBox组件并覆盖updateDisplayList方法,如下所述:-
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var cornerRadius:Number = getStyle("cornerRadius");
var backgroundColor:int = getStyle("backgroundColor");
var backgroundAlpha:Number = getStyle("backgroundAlpha");
graphics.clear();
// Background
drawRoundRect(0, 0, unscaledWidth, unscaledHeight,
{tl: 0, tr: 0, bl: cornerRadius, br: cornerRadius},
backgroundColor, backgroundAlpha);
}
在flex3中,我会使用borderskin而不是扩展VBox。但我建议你选择flex4(我的意见) ============================================================================== 在flex4中 您必须使用skin类,并且s:Rect有一个属性,您可以使用该属性将不同的角半径应用于所有四个角 查看此链接: 可以将BorderContainer与垂直布局一起使用 VGroup在VBox中也存在,但它不支持蒙皮(我的意思是没有定义skinClass属性)
——未定义
----定义,应用自定义蒙皮
所以BorderContainer是gud 1,具有垂直布局
谢谢
Ankur试试这个:-像这样修改上面的代码(代码由--user1367714)
我怀疑您必须扩展组件才能做到这一点;我不太清楚它是如何在幕后实现的。如果你在Flex4上;您可以使用带有自定义外观的BorderContainer来完成此操作。感谢您的回答,它似乎不起作用。drawRoundRect()有6个参数,这里有7个参数。请查找我修改过的代码,它已从MXML标记中删除backgroundColor属性。通过添加setter和getter属性并添加您定义的颜色,可以发送相同的内容。
<s:VGroup skinClass=""/>----not defined
<s:BorderContainer skinClass="bcSkin"/>----defined, apply custom skin
<?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" minWidth="955" minHeight="600" xmlns:local="*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<local:stackOverflowCornerRadious x="50" y="50" width="200" height="200"/>
</s:Application>
package
{
import flash.display.Sprite;
import mx.containers.Box;
import mx.containers.VBox;
import mx.utils.GraphicsUtil;
import spark.primitives.Rect;
public class stackOverflowCornerRadious extends VBox
{
public function stackOverflowCornerRadious()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
graphics.clear();
graphics.beginFill(0x00FF00);
GraphicsUtil.drawRoundRectComplex(graphics,0,0,unscaledWidth,unscaledHeight,0,0,10,10)
graphics.endFill();
}
}
}