flex显示一条直线
flex显示一条直线,如何做到?不是用鼠标画直线,而是直接显示直线。以下是代码:<?xmlversion="1.0"encoding="utf-8"?><mx:Appli...
flex显示一条直线,如何做到?不是用鼠标画直线,而是直接显示直线。
以下是代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import com.Xian;
function init():void{
var xian:Xian = new Xian();
xian.aa();
myCanvas.addChild(xian);
}
]]>
</mx:Script>
<mx:Canvas id="myCanvas" width="100%" height="100%" >
</mx:Canvas>
</mx:Application>
Xian.as文件如下:
package com
{
import flash.geom.Point;
import mx.core.UIComponent;
public class Xian extends UIComponent
{
public function Xian()
{
super();
}
public function aa(){
this.graphics.clear();
var startPoint:Point = new Point(10,50);
var endPoint:Point = new Point(200,200);
this.graphics.moveTo(startPoint.x,startPoint.y);
this.graphics.lineTo(endPoint.x,endPoint.y);
}
}
}
可是展示不出来什么东西,说明在aa()方法中的这种写发是不对的,那么该怎么写呢? 展开
以下是代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import com.Xian;
function init():void{
var xian:Xian = new Xian();
xian.aa();
myCanvas.addChild(xian);
}
]]>
</mx:Script>
<mx:Canvas id="myCanvas" width="100%" height="100%" >
</mx:Canvas>
</mx:Application>
Xian.as文件如下:
package com
{
import flash.geom.Point;
import mx.core.UIComponent;
public class Xian extends UIComponent
{
public function Xian()
{
super();
}
public function aa(){
this.graphics.clear();
var startPoint:Point = new Point(10,50);
var endPoint:Point = new Point(200,200);
this.graphics.moveTo(startPoint.x,startPoint.y);
this.graphics.lineTo(endPoint.x,endPoint.y);
}
}
}
可是展示不出来什么东西,说明在aa()方法中的这种写发是不对的,那么该怎么写呢? 展开
1个回答
展开全部
var startPoint:Point = new Point(10,50);
var endPoint:Point = new Point(200,200);
this.graphics.beginFill(0xffff00);//线的颜色
this.graphics.lineStyle(1.5,0,1);//线的样式,必须加
this.graphics.moveTo(0,0);
this.graphics.lineTo(100,100);
var endPoint:Point = new Point(200,200);
this.graphics.beginFill(0xffff00);//线的颜色
this.graphics.lineStyle(1.5,0,1);//线的样式,必须加
this.graphics.moveTo(0,0);
this.graphics.lineTo(100,100);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询