flex画图类的问题: 问题一:在flex中写一个画图类与在flash cs3中写这个类有何区别? 问题二:看下面
帮我看看下面这个类的写法,为什么第一种可以,而第二种则是空白--------------------------可行的写法--------------------pack...
帮我看看下面这个类的写法,为什么第一种可以,而第二种则是空白
--------------------------可行的写法--------------------
package xian
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import mx.containers.Canvas;
public class Xianborder extends Canvas
{
var xians:Sprite=new Sprite();//
var xianx:Array=new Array();//
var xiany:Array=new Array();//
var key:String;
public function Xianborder ()
{
//
xianx=[97.5,37.5,95.4,93.5];
xiany=[62.7,44.9,65.4,45.1];
var ls:int=0;
var s1:int;
ls=xianx.length;
graphics.lineStyle(3,0x007500);
graphics.moveTo(xianx[0],xiany[0]);
for(var i=1;i<ls-1;i++)
{
graphics.lineTo(xianx[i],xiany[i]);
}
//addChild(xians);
}
}
}
-----------------------------------------------------------
----------下面这个不能,是空白的-------
package xian
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import mx.containers.Canvas;
public class Xianborder extends Canvas
{
var xians:Sprite=new Sprite();//
var xianx:Array=new Array();//
var xiany:Array=new Array();//
var key:String;
public function Xianborder ()
{
//
xianx=[97.5,37.5,95.4,93.5];
xiany=[62.7,44.9,65.4,45.1];
var ls:int=0;
var s1:int;
ls=xianx.length;
xians.graphics.lineStyle(3,0x007500);
xians.graphics.moveTo(xianx[0],xiany[0]);
for(var i=1;i<ls-1;i++)
{
xians.graphics.lineTo(xianx[i],xiany[i]);
}
addChild(xians);
}
}
}
为什么会这样?
如果我想用类似于第二种方法,如何做?因为我要好几十个分离的密闭曲线,并且为各个区域添加事件等,因此我希望每个密闭的曲线有其对应的对象名 展开
--------------------------可行的写法--------------------
package xian
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import mx.containers.Canvas;
public class Xianborder extends Canvas
{
var xians:Sprite=new Sprite();//
var xianx:Array=new Array();//
var xiany:Array=new Array();//
var key:String;
public function Xianborder ()
{
//
xianx=[97.5,37.5,95.4,93.5];
xiany=[62.7,44.9,65.4,45.1];
var ls:int=0;
var s1:int;
ls=xianx.length;
graphics.lineStyle(3,0x007500);
graphics.moveTo(xianx[0],xiany[0]);
for(var i=1;i<ls-1;i++)
{
graphics.lineTo(xianx[i],xiany[i]);
}
//addChild(xians);
}
}
}
-----------------------------------------------------------
----------下面这个不能,是空白的-------
package xian
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
import mx.containers.Canvas;
public class Xianborder extends Canvas
{
var xians:Sprite=new Sprite();//
var xianx:Array=new Array();//
var xiany:Array=new Array();//
var key:String;
public function Xianborder ()
{
//
xianx=[97.5,37.5,95.4,93.5];
xiany=[62.7,44.9,65.4,45.1];
var ls:int=0;
var s1:int;
ls=xianx.length;
xians.graphics.lineStyle(3,0x007500);
xians.graphics.moveTo(xianx[0],xiany[0]);
for(var i=1;i<ls-1;i++)
{
xians.graphics.lineTo(xianx[i],xiany[i]);
}
addChild(xians);
}
}
}
为什么会这样?
如果我想用类似于第二种方法,如何做?因为我要好几十个分离的密闭曲线,并且为各个区域添加事件等,因此我希望每个密闭的曲线有其对应的对象名 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询