Question

I am using a canvas which has a degrafa background, so far so good.

However, when scrolling, the background (degrafa grid) does not get redrawn. In the code the background strokes are linked to the container height. The container height does not change even when scrolling.

How do I get the height of the whole area so I can set the new height to my degrafa background?

It looks like this:

degrafa background example

 <mx:Canvas id="blackBoard"
                width="100%" 
                height="100%" 
                x="0" 
                y="0" 
                backgroundColor="#444444"
                clipContent="true">

    <!-- Degrafa Surface   -->
    <degrafa:Surface id="boardSurfaceContainer">
            <degrafa:strokes>
                <degrafa:SolidStroke    id="whiteStroke"
                                        color="#EEE"
                                        weight="1"
                                        alpha=".2"/>
            </degrafa:strokes>

            <!-- Grid drawing -->
            <degrafa:GeometryGroup id="grid">
                <degrafa:VerticalLineRepeater   count="{blackBoard.width / ApplicationFacade.settings.GRID_SIZE}"
                                                stroke="{whiteStroke}"
                                                x="0"
                                                y="0"
                                                y1="{blackBoard.height}"
                                                offsetX="0"
                                                offsetY="0"
                                                moveOffsetX="{ApplicationFacade.settings.GRID_SIZE}"
                                                moveOffsetY="0"/>

                <degrafa:HorizontalLineRepeater count="{blackBoard.height / ApplicationFacade.settings.GRID_SIZE}"
                                                stroke="{whiteStroke}"
                                                x="0"
                                                y="0"
                                                x1="{blackBoard.width}"
                                                offsetX="0"
                                                offsetY="0"
                                                moveOffsetX="0"
                                                moveOffsetY="{ApplicationFacade.settings.GRID_SIZE}"/>

            </degrafa:GeometryGroup>          

        </degrafa:Surface>
Was it helpful?

Solution

I just had to use the scroll position in the degrafa property binding

            <degrafa:VerticalLineRepeater   count="{(blackBoard.width + blackBoard.horizontalScrollPosition)/ ApplicationFacade.settings.GRID_SIZE}"
                                            stroke="{whiteStroke}"
                                            x="0"
                                            y="0"
                                            y1="{blackBoard.height + blackBoard.verticalScrollPosition}"
                                            offsetX="0"
                                            offsetY="0"
                                            moveOffsetX="{ApplicationFacade.settings.GRID_SIZE}"
                                            moveOffsetY="0"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top