I believe I might be missing something with the Decorator Pattern.
I've tried to get a simple example to work, but I get too mixed up
with all the abstracts and what not.

Here's what I'm trying to do:

Extend a Button and add some functionality to it gotten from another
class (non visual). From what I can understand, this is what the
Decorator Pattern is for.

In pseudo code this is the basic functionality I want:

class JuiceMaster
{
    public function makeJuice(type:String):void
    {
        trace("Happily making", type,  "juice!", "Tralalala!");
    }
}

class JuiceMaker extends Button
{
    public function JuiceMaker()
    {
        Super();
        makeJuice("apple");
    }
}

And in MXML, I should be able to do something like this:

<JuiceMaker id="myJuiceMaker" click="myJuiceMaker.makeJuice('orange')" />

Of course this example isn't going into any detail, and doesn't make
much sense, but this is somewhat my need.

Any explicit explanation on how to get something like this to work
with the Decorator Pattern is greatly appreciated.

Thanks!

Reply via email to