IBitmapDrawable question

I’m trying to make a class that will resize a bitmap to a defined size by passing in the display object to be resized plus the dimensions to resize to. I want the class to return a bitmapdata object of the resized image.

I’m using the IBitmapDrawable interface to make sure the passed in object can be used by the draw method of BitmapData.

I simply want to know how I can get the width of the passed object from the IBitmapDrawable interface. I currently get this error message :

“1119: Access of possibly undefined property width through a reference with static type flash.display:IBitmapDrawable”.

I believe I may need to cast the IBitmapDrawable to some other kind of display object in order to be able to access the width properties, however I’m not quite sure how to do this. Any help would be great.

Simplified code below which produces the above error.

package {
    import flash.display.BitmapData;
    import flash.display.IBitmapDrawable;
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.display.DisplayObject;

    public class BitmapResizer extends Sprite {
        public function BitmapResizer (displayObject:IBitmapDrawable) {
            trace (displayObject.width);