Degrafa 贝塞尔样条线将数据绑定到字符串

发布于 2024-07-22 17:38:33 字数 900 浏览 10 评论 0原文

我想通过以下代码将贝塞尔样条线插入我的画布:

<mx:Canvas 
id="graphCanvas" 
width="100%" 
height="100%" 
preinitialize="preInit()"
/>
<BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}"  data="points"

verticalCenter =“0”horizo​​ntalCenter =“0” >

点是我在 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”horizo​​ntalCenter =“0” >

有人能帮我吗? 我需要动态更改样条线的数据。 也欢迎以编程方式处理它的答案,因为我真的不知道如何通过代码在画布上重绘样条线(不知道如何使用样条线的 draw() 方法)。

预先感

谢塞巴斯蒂安

I want to insert a bezier spline into my Canvas by this code

<mx:Canvas 
id="graphCanvas" 
width="100%" 
height="100%" 
preinitialize="preInit()"
/>
<BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}"  data="points"

verticalCenter="0" horizontalCenter="0"
>

points is a string I initialize in the preInit() method

[Bindable]public var points : String;
private function preInit() : void {
        points = "200,100 200,300 100,300 300,500 500,300 400,300 400,100";
    }

But when I now build the project no spline is drawn on my canvas whereas directly integrating the data in the mxml works

<BezierSpline id="mySpline" graphicsTarget="{[graphCanvas]}"  data="200,100 200,300 100,300 300,500 500,300 400,300 400,100"

verticalCenter="0" horizontalCenter="0"
>

Can someone help me? I need to dynamically change the data of the spline. Also answers that handle it programmatically are welcome as I do not really know how to redraw the spline on my canvas by code (don't know how to use the draw() method of the spline).

Thanks in advance

Sebastian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丢了幸福的猪 2024-07-29 17:38:33

这段代码对我有用:

[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>

This code works for me:

[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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文