>     ClassName(instance) is marginally faster than (instance as
 >     ClassName) in my tests.

So which one is faster? Is this still correct?

(us lurkers want to know! :)
_______________________________________________________________________

Joseph Balderson | http://joeflash.ca
Flex & Flash Platform Developer | Abobe Certified Developer & Trainer
Author, Professional Flex 3 (coming Winter 2008)
Staff Writer, Community MX | http://communitymx.com/author.cfm?cid=4674



Josh McDonald wrote:
> Goddammit, I've been going about it ass backwards! *kicks self*
> 
> Thanks Alex.
> 
> -J
> 
> On Thu, Jun 5, 2008 at 4:15 PM, Alex Harui <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     Var foo:MyClass = MyClass(wrongInstance); //throws exception
> 
>     Var bar:MyClass = wrongInstance as MyClass; // returns null unless
>     it can be coerced (usually with primitive types)
> 
>      
> 
>     ------------------------------------------------------------------------
> 
>     *From:* flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>
>     [mailto:flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>] *On Behalf Of *Josh McDonald
>     *Sent:* Wednesday, June 04, 2008 10:40 PM
> 
>     *To:* flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com>
>     *Subject:* Re: [flexcoders] Re: Retrieving instence name?
> 
>      
> 
>     I've read that ClassName(wrongInstance) just gives null? Hence you
>     get a nullpointer exception even though that's not really your
>     problem, and a newb in his debugger that sees a nullpointer
>     exception when wrongInstance is clearly not null is gonna be awfully
>     confused.
> 
>     -Josh
> 
>     On Thu, Jun 5, 2008 at 3:14 PM, Alex Harui <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     ClassName(instance) is marginally faster than (instance as
>     ClassName) in my tests.
> 
>      
> 
>     Something's gonna blow if it isn't that type.  I don't have any hard
>     rules on which to use though.  I also think there are cases where
>     you need to use "as"  and vice versa due to coercion rules, but I
>     could be wrong about that.
> 
>      
> 
>     ------------------------------------------------------------------------
> 
>     *From:* flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>
>     [mailto:flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>] *On Behalf Of *Josh McDonald
>     *Sent:* Wednesday, June 04, 2008 9:16 PM
>     *To:* flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com>
>     *Subject:* Re: [flexcoders] Re: Retrieving instence name?
> 
>      
> 
>     Isn't ClassName(instance).foo a bad idea now we have (instance as
>     ClassName).foo? I'd much rather have a NPE when it's actually null,
>     and a CCE when instance isn't a ClassName.
> 
>     -Josh
> 
>     On Thu, Jun 5, 2008 at 1:55 PM, Alex Harui <[EMAIL PROTECTED]
>     <mailto:[EMAIL PROTECTED]>> wrote:
> 
>     Code hints will not help when dealing with event.target unless you
>     know what it is.  Technically you should code lit like
> 
>      
> 
>     LoaderInfo(event.target).loader
> 
>      
> 
>     And hopefully, you'll get code hints when you type the '.' before
>     loader.
> 
>      
> 
>     ------------------------------------------------------------------------
> 
>     *From:* flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>
>     [mailto:flexcoders@yahoogroups.com
>     <mailto:flexcoders@yahoogroups.com>] *On Behalf Of *flexawesome
>     *Sent:* Wednesday, June 04, 2008 7:28 PM
> 
> 
>     *To:* flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com>
>     *Subject:* [flexcoders] Re: Retrieving instence name?
> 
>      
> 
>     Woowow Ales, you are the BEST!!!! :))
> 
>     How do you know the property of event.target.loader? I was unable to
>     see the property by using "cdoe tip"
> 
>     Cheers
> 
>     --- In flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com>, "Alex Harui" <[EMAIL PROTECTED]> 
> wrote:
>     >
>     >  Sorry, I actually hadn't looked at your code before.
>     >
>     >
>     >
>     >  The target/currentTarget will be a LoaderInfo. Target.loader.name
>     <http://Target.loader.name>
>     is
>     >  probably what you want.
>     >
>     >
>     >
>     >  ________________________________
>     >
>     >  From: flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com>
>     [mailto:flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com>] On
>     >  Behalf Of flexawesome
>     >  Sent: Wednesday, June 04, 2008 2:19 PM
>     >  To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
>     >  Subject: [flexcoders] Re: Retrieving instence name?
>     >
>     >
>     >
>     >
>     >  Hey Alex, I was unable to retrieve the instance name..
>     >
>     >  I got trace info. => [object LoaderInfo]
>     >
>     >  Any hits?
>     >
>     >  --- In flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
>     <mailto:flexcoders%25>
>     40yahoogroups.com <http://40yahoogroups.com>>
>     >  , "Alex Harui" <aharui@> wrote:
>     >  >
>     >  > Try event.currentTarget.toString()
>     >  >
>     >  >
>     >  >
>     >  > ________________________________
>     >  >
>     >  > From: flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
>     <mailto:flexcoders%25>
>     40yahoogroups.com <http://40yahoogroups.com>>
>     >
>     >  [mailto:flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
>     <mailto:flexcoders%25>
>     40yahoogroups.com <http://40yahoogroups.com>>
>     >  ] On
>     >  > Behalf Of flexawesome
>     >  > Sent: Wednesday, June 04, 2008 1:25 PM
>     >  > To: flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com> <mailto:flexcoders%
>     <mailto:flexcoders%25>
>     40yahoogroups.com <http://40yahoogroups.com>>
>     >  > Subject: [flexcoders] Re: Retrieving instence name?
>     >  >
>     >  >
>     >  >
>     >  > event.currentTarget.name <http://event.currentTarget.name> seem
>     doesn't work. :(
>     >  >
>     >  > --- In flexcoders@yahoogroups.com
>     <mailto:flexcoders%40yahoogroups.com>
>     >  <mailto:flexcoders%40yahoogroups.com
>     <mailto:flexcoders%2540yahoogroups.com>> <mailto:flexcoders%
>     <mailto:flexcoders%25>
>     >  40yahoogroups.com <http://40yahoogroups.com>>
>     >  > , "flexawesome" <flexawesome@>
>     >  > wrote:
>     >  > >
>     >  > > Hey, is that possible to retrieve the instence name for
>     imgLoad ?
>     >  > >
>     >  > > # in this example, it calls init2 from init1 and know the
>     >  instence
>     >  > name
>     >  > > is "test" but I would like to retrieve it from event or other
>     >  ways,
>     >  > is
>     >  > > that possible?
>     >  > >
>     >  > >
>     >  > > http://www.privatepaste.com/e4RWWrMIAW
>     >  <http://www.privatepaste.com/e4RWWrMIAW>
>     >  > <http://www.privatepaste.com/e4RWWrMIAW
>     >  <http://www.privatepaste.com/e4RWWrMIAW> >
>     >  > >
>     >  > > Thank you
>     >  > >
>     >  >
>     >
> 
> 
> 
> 
>     -- 
>     "Therefore, send not to know For whom the bell tolls. It tolls for
>     thee."
> 
>     :: Josh 'G-Funk' McDonald
>     :: 0437 221 380 :: [EMAIL PROTECTED] <mailto:[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] <mailto:[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] <mailto:[EMAIL PROTECTED]> 

Reply via email to