I've been working on a way to dynamically load images into a Flex app and set them as the tiled background of a Canvas component. Luckily I spotted creacog's work which I adapted a little bit for my needs. You can see the results here.
So far the image loading and displaying as a borderskin of the Canvas works, but as you can see when you drag the box around is that as soon as scrollbars appear the image is no longer rendered and the Canvas's background color it displayed instead.
I'd appreciate any tips on this. You can see the sources by right-clicking the app or directly from here (the .zip is here).
Feel free to use and reuse this code if you find it useful, and remember to credit creacog.co.uk who has done the hard work on this.


The way I resolved it was to have hidden canvases around the main canvas which the image could be moved into and switching of Auto Scroll bars.
Thus having a fixed area on the screen which the image can move round and into.
Enabling the background to stay static.
Well a brief explanation but hopefully enough for a solution.
Found this method
http://alekkus.com/blog/2009/02/flex-tutorial-sett...
implemented it into your mxml, works fine:
http://buffer.uk.com/preview/flex/bin-release/Imag...
hth,
Neil
Some info on whats going on:
When a Container has ScrollBars added to it, it creates a new Sprite inside itself named contentPane, to hold the children, removes the children from itself, and adds the to the contentPane. It then scrolls the view by using a scrollRect on the contentPane.
The contentPane has some of the styles set on the Canvas applied to it (namely background stuff (backgroundDisabledColor, backgroundColor, backgroundAlpha, backgroundImage, background)), and this sits on top of the border which remains at index 0 within the Canvas's rawChildren.
Easiest hack:
Set the backgroundAlpha style to 0. The exact same thing will be happening, but because the background alpha is 0, u won't see it and therefore you will see your 'border' below it.
Thanks for the explanation, with knowing about the contentPane it makes more sense.
So another alternative would be to use the built in style 'backgroundImage' to assign the image, and use that in your skin, instead of adding another style to do the same thing (i.e. your 'bgImage').
I guess it depends on your specific implementation.