Decorator Pattern and loading in from library

Hi,

I’ve been following this tutorial:

http://www.as3dp.com/2009/04/26/actionscript-30-easy-and-practical-decorator-design-pattern/

And so far everything is working. However, I want my Concrete class to load in an item from the library (basically the graphic for that item). This works fine when just loading in the Concrete class, but as soon as I add a decorator the graphic disappears, and I’m not sure why.

The code so far is:

My Abstract Class

package todd.flashBook.navigation{
    
    import flash.display.MovieClip;
    
    public class navButton extends MovieClip{
        
        public function navButton():void{
            trace("Nav button Created");
        }
        
    }
    
}

Abstract Decorator

package todd.flashBook.navigation{
    
    public class navButtonDecorator extends navButton{
        
        protected var button:navButton;
        
    }
    
}

Concrete Class

package todd.flashBook.navigation{
    
    public class prevButton extends navButton{
        
        public function prevButton():void{
            trace("I am a previous button");
        }
        
    }
    
}

Concrete Decorator

package todd.flashBook.navigation{
    
    public class pageSkipDecorator extends navButtonDecorator{
        
        public function pageSkipDecorator(buttonRef:navButton){
            this.button = buttonRef;
        }
        
        public function skipToPage(pageNum:Number){
            
            trace("skipping to page");
            
        }
        
    }
    
}

Everything works, I can call functions from each, just the graphic goes.

I’m calling the Class like this:

var button = new pageSkipDecorator(new prevButton());

I’m pretty sure I understand how the Decorator pattern works (bar the reference to the component in the decorator abstract class), but I’m not sure why the graphic isn’t showing. I get no errors either. This seems like a useful pattern, and I can already think of ways I can use it in future projects, but not without this stumbling block :frowning:

Cheers if anyone can shed some light!