tags:

views:

455

answers:

1
<degrafa:LinearGradientFill id="bluedream">
        <degrafa:GradientStop color="#6ab5d0"/>
        <degrafa:GradientStop color="#388aae"/>
</degrafa:LinearGradientFill>

<degrafa:GeometryComposition graphicsTarget="{[bgCanvas]}">
        <degrafa:RoundedRectangle id="color_preset" fill="{bluedream}"/>
</degrafa:GeometryComposition>

I have issue with degrafa code which I have defined a set of different gradients for color_preset.fill to be dynamic change when user select different color in the combobox.

I replaced fill="{bluedream}" with fill="using_variable" and lead to error compiled message: Initializer for 'fill': values of type com.degrafa.core.IGraphicsFill cannot be represented in text.

Is there a solution to use this code as a color changer?

A: 

The fill property in your example is pointing to the LinearGradientFill with id "bluedream". You can either replace the fill with a different gradient (or solid or other fill) or change the colors of the gradient fill itself:

<degrafa:LinearGradientFill id="bluedream">
    <degrafa:GradientStop color="{your_combobox.selectedItem}"/>
    <degrafa:GradientStop color="{your_other_combobox.selectedItem}"/>
</degrafa:LinearGradientFill>

<degrafa:GeometryComposition graphicsTarget="{[bgCanvas]}">
     <degrafa:RoundedRectangle id="color_preset" fill="{bluedream}"/>
</degrafa:GeometryComposition>

I haven't run that code, but it should work. The idea is to change the color of the GradientStop with your dropdown's selectedItem (provided that is a string). This example does something very similar, but with a color picker instead of a dropdown: http://degrafa.org/source/CS4IconPreviewer/CS4IconPreviewer.html

Laura