Search code examples
apache-flexflashsplinedegrafa

Degrafa Bezier spline bind data to string


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


Solution

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