flex线条画一个图形然后填充颜色,50分哦
问题如标题,比如画三条直线首尾相连成三角形,然后在三角形里填充颜色。怎么用flex实现。
[解决办法]
<?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" > <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <s:Graphic x="0" y="0"> <s:Path data="M 50 0 L 0 100 L 100 100 L 50 0"> <s:stroke> <s:SolidColorStroke color="#99BBE8" /> </s:stroke> <s:fill> <s:SolidColor color="#99BBE8" alpha="0.2" /> </s:fill> </s:Path> </s:Graphic></s:Application>
[解决办法]
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()"
backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function init():void{
var shape:Sprite=new Sprite();
var comp:UIComponent = new UIComponent();
comp.addChild(shape);
shape.graphics.lineStyle(2);
shape.graphics.beginFill(0xffd200,1.0);
shape.graphics.moveTo(0,100);
shape.graphics.lineTo(-150,250);
shape.graphics.lineTo(150,250);
shape.graphics.lineTo(0,100);
shape.graphics.endFill();
addChild(comp);
}
]]>
</mx:Script>
</mx:Application>
以上只是说明方法,实际应用中应当封装成AS类