If you don't want to use a mix-in, a classthat
basically adds stuff at runtime to an existing class (which from an OOP
standpoint & Flex' future career, you shouldn't do, but from a Functional
standpoint + Decorator is perfectly legal), then use Manish's example; he uses
inheritance, much like the TitleWindow extends Panel and has a close
button;
Also, Christophe Coenraets also has a great example
of extending Panel:
(if his site fails, hit refresh)
----- Original Message -----
Sent: Thursday, February 03, 2005 5:46
AM
Subject: [flexcoders] Attempting to add a
button to Panel titlebar
Fellow Flexcoders,
So I have been trying to place a
button in the titlebar of one of my panels and started digging around. I
remembered Jesse had put up an example of a mix-in class ( http://www.jessewarden.com/archives/2005/01/collapseable_pa.html
) for doing just that. I dug through the code and have had no luck. I have
included the actionscript from my test file at the end of this
message.
so my questions are:
1) Jesse, what voodoo do you do to
get that to work? ;) 2) Everyone, is there a different way I can do this?
Is Jesse's way the most efficient /
elegant?
Thanks, Seth
Code:
myPanel.mxml (root element
is <mx:Panel /> with the following in a script tag, not including
includes)
import
mx.utils.*; import de.richinternet.utils.Dumper;
private var menu_pb
: Button;
public function initFunk ( ) { Dumper.dump ( "Init..."
); _initMenuButton ( this ); // Not sure why I have to do this, but I don't
got compile errors on menu_pb with this. }
static private function
_initMenuButton ( obj ) { Dumper.dump ( "Init 2..."
);
obj.> obj.createClassObject (
Button, "menu_pb", obj.getNextHighestDepth ( )); obj.menu_pb.label =
">"; obj.menu_pb.setSize ( 22, 22 ); obj.menu_pb.addEventListener (
"click", Delegate.create ( obj, obj.onMenuButton )); }
private
function onMenuButton ( ) { Dumper.dump ( "Trace: fileShare.onMenuButton()"
); }
static private function _sizeOverload ( obj ) { Dumper.dump
( "Size 2..." ); obj.super.size ( ); obj.menu_pb.move ( obj.width -
obj.menu_pb.width - 8, 4 ); }
function size ( ) : Void
{ Dumper.dump ( "Size..." ); super.size ( ); _sizeOverload ( this
); }
/* All dumps to the tracer are accounted for and in the
expected order... *//smaller>/fontfamily>
|