我想通过此代码
将一个贝塞尔样条插入我的画布中<mx:Canvas
id="graphCanvas"
width="100%"
height="100%"
preinitialize="preInit()"
/>
<BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}" data="points"
verticalCenter =“0”horizontalCenter =“0” &GT;
points是我在preInit()方法中初始化的字符串
[Bindable]public var points : String;
private function preInit() : void {
points = "200,100 200,300 100,300 300,500 500,300 400,300 400,100";
}
但是当我现在构建项目时,我的画布上没有绘制样条曲线,而是直接将数据集成到mxml中
<BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}" data="200,100 200,300 100,300 300,500 500,300 400,300 400,100"
verticalCenter =“0”horizontalCenter =“0” &GT;
有人能帮助我吗?我需要动态更改样条曲线的数据。也欢迎以编程方式处理它的答案,因为我真的不知道如何通过代码在我的画布上重绘样条线(不知道如何使用样条线的draw()方法)。
提前致谢
塞巴斯蒂安
答案 0 :(得分:1)
此代码适用于我:
[Bindable]
private var points:String;
private function preinit ():void
{
points = "200,100 200,300 100,300 300,500 500,300 400,300 400,100";
}
<degrafa:BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}" data="{points}">
<degrafa:stroke>
<degrafa:SolidStroke weight="2" color="#0000FF"/>
</degrafa:stroke>
</degrafa:BezierSpline>