I am now trying to dynamically insert a Canvas component with
an image component inside of it. I need to re-used the code for
many images. Apparently it is only working if I give the canvas a
width and height, which needs to be the size of the image file.
Images are just display objects. You should be able to grab
the measuredWidth and measuredHeight properties off of it to
determine how big your canvas needs to be. If you're dynamically
changing the source of your image, watch for the dataChange event
that the image dispatches when its source changes.