Quick test:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="cc()">
<mx:Script>
<![CDATA[
import flash.utils.getDefinitionByName;
import flash.utils.describeType;
import flash.utils.getQualifiedClassName;
private function cc():void
{
trace("component == ");
trace(getQualifiedClassName(component));
trace("");
trace("component.newInstance() == ");
trace(getQualifiedClassName(component.newInstance()));
trace("");
//Check for runtime exception
try
{
getDefinitionByName("NewComponent");
trace("getDefinitionByName success");
}
catch (e:*)
{
trace("getDefinitionByName fail");
}
}
]]>
</mx:Script>
<mx:Component id="component" className="NewComponent">
<mx:Canvas>
<mx:Button id="button1" label="Button 1!"/>
</mx:Canvas>
</mx:Component>
</mx:Application>
Yields:
component ==
mx.core::ClassFactory
component.newInstance() ==
NewComponent
getDefinitionByName success
Also looked at describeType for newInstance() - it seems it's creating a
proper subclass of Canvas, in the global namespace.
The MXMLC compiler is smart enough to resolve and compile the following:
var t:NewComponent = new NewComponent();
But Builder's not smart enough to ctrl-click to the <mx:component>
definition.
-Josh
On Fri, Jul 25, 2008 at 3:52 AM, Alex Harui <[EMAIL PROTECTED]> wrote:
> Yes, I think you can specify the name of the class as you did. Not sure
> if it gets further decorated or what happens if you have a collision of
> names.
>
>
> ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Josh McDonald
> *Sent:* Wednesday, July 23, 2008 11:52 PM
> *To:* [email protected]
> *Subject:* Re: [flexcoders] Re: new Component() ?
>
>
>
> If you have:
>
> <mx:Component id="inlineEditor" className="MyClass">
> <mx:Canvas/>
> </mx:Component>
>
> You get a subclass of Canvas named MyClass, and a local public scoped
> instance of an IFactory called inlineEditor, right?
>
> -Josh
>
> On Thu, Jul 24, 2008 at 3:36 PM, Alex Harui <[EMAIL PROTECTED]> wrote:
>
> If you've defined a component via <mx:Component>, the name is
> auto-generated as Josh says, but it generates an IFactory, so you can use
> the factory to get new instances
>
>
>
> <mx:List id="myList>
>
> <mx:itemRenderer>
>
> <mx:Component>
>
> <mx:Canvas>
>
> ..
>
>
>
>
>
> From AS:
>
>
>
> myList.itemRenderer.newInstance()
>
>
> ------------------------------
>
> *From:* [email protected] [mailto:[EMAIL PROTECTED] *On
> Behalf Of *rafaelrfc00
> *Sent:* Wednesday, July 23, 2008 9:53 PM
> *To:* [email protected]
> *Subject:* [flexcoders] Re: new Component() ?
>
>
>
> Text was just an example.
>
> It can be date, text, textarea, some other customcomponents. I was
> just curious how i would create item renderes without creating a file.
>
> I thought if you are able to use <mx:component> you would be able to
> create it from actionscript as well.
>
> guess i was wrong. Flex didn't think about everything, do they? :P
>
> raf
>
> --- In [email protected] <flexcoders%40yahoogroups.com>, "Josh
> McDonald" <[EMAIL PROTECTED]> wrote:
> >
> > Well no, you can't do what you're asking :)
> >
> > When you use:
> >
> > <mx:component>
> > <canvas>
> > ...
> > </canvas>
> > </mx:component>
> >
> > It's creating a new subclass of Canvas with a generated name, and
> you can't
> > create new classes at run-time without bytecode manipulation (which
> isn't
> > really an option in Flex yet unfortunately).
> >
> > But what exactly are you trying to achieve? If you're just
> displaying text,
> > but it needs to be different to the field data, what you need is a
> > labelFunction, not an itemRenderer.
> >
> > -Josh
> >
> > On Thu, Jul 24, 2008 at 10:34 AM, Rafael Faria <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Hi Pedro,
> > >
> > > How do you mean about putting some getters? Can you give me an
> example?
> > >
> > > Thanks
> > > Raf
> > >
> > >
> > > --- In [email protected] <flexcoders%40yahoogroups.com>,
> "Pedro Sena" <sena.pedro@> wrote:
> > > >
> > > > Hi Rafael,
> > > >
> > > > What do u think of put some getters in your object instead of create
> > > various
> > > > item renderers that just have little funcionality ?
> > > >
> > > > Just my 2 cents
> > > >
> > >
> > >
> > > ------------------------------------
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > > Links
> > >
> > >
> > >
> > >
> >
> >
> > --
> > "Therefore, send not to know For whom the bell tolls. It tolls for
> thee."
> >
> > :: Josh 'G-Funk' McDonald
> > :: 0437 221 380 :: [EMAIL PROTECTED]
> >
>
>
>
>
> --
> "Therefore, send not to know For whom the bell tolls. It tolls for thee."
>
> :: Josh 'G-Funk' McDonald
> :: 0437 221 380 :: [EMAIL PROTECTED]
>
>
>
--
"Therefore, send not to know For whom the bell tolls. It tolls for thee."
:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]