Here is a class that extends VBox:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox
xmlns:mx="http://www.macromedia.com/2003/mxml"
width="400" height="400">
</mx:VBox>
If you save that as MyVBox.mxml, you can then use it elsewhere as:
<jxl:MyVBox xmlns:jxl="*" />
Or:
import MyVBox;
createChild(MyVBox);
If I want to give my class methods, I can do:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox
xmlns:mx="http://www.macromedia.com/2003/mxml"
width="400" height="400">
<mx:Script>
<![CDATA[
public function method():Void
{
trace("yo");
}
]]>
</mx:Script>
</mx:VBox>
Same as:
import mx.containers.VBox;
class MyVBox extends VBox
{
public function method():Void
{
trace("yo");
}
}
----- Original Message -----
From: "Trey Long" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, January 20, 2006 3:50 PM
Subject: Re: [flexcoders] MXML Components and Classes
So you're saying just extend a standard MXML component with an mx:script
include on line #2. And it should associate the AS file with the class
of the MXML component?
Well, that sounds hacky :) I hope this is addressed for the Beta.
-Trey
JesterXL wrote:
> You can create ActionScript or MXML class; they are effectively the same
> thing. The only real "limitation" I've found is I've failed to create
> extensible containers via MXML; meaning, extending CheckBox, Label,
> Loader,
> with MXML works great, but extending Containers like VBox, Panel, etc.
> gave
> me problems. I can't remember if it WAS supposed to have 1 child or NOT
> supposed to have any children... anyway, if you use ActionScript, works
> like
> a charm, but I like MXML better.
>
> If the <mx:Script tag is the first tag after Application, those methods
> will
> become class methods, just like others. If you put it after uicomponents,
> I
> think it just becomes like an include instead. You can still put it after
> mx:Style and mx:Metadata tags which is cool..
>
> ----- Original Message -----
> From: "Trey Long" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Friday, January 20, 2006 12:12 PM
> Subject: [flexcoders] MXML Components and Classes
>
>
> Quick question about making custom components.
>
> I know custom components exist as classes in actionscript but I was a
> little lost on how you create functions for your component. Right now I
> have an external .AS file that is just some import statements and a
> collection of functions (no package or class definition). How can I link
> the .MXML component to a class, or write the components class code? Is
> it possible to have a hybrid component or must the whole thing be in
> actionscript if I want any programmatic functionality?
>
> -Trey
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/