I messed up, what I said does not work, to early in the morning for me. :)
'is' tests an instance to a class reference. I was thinking in the opposite
direction when I gave that example.

Eric shows you.

Mike

On Mon, Oct 27, 2008 at 11:41 AM, Eric Cooper <[EMAIL PROTECTED]> wrote:

>   The question has been answered (yes, it is possible to use "is" as part
> of isInstanceOf() method. Here's an example of my use of
> this mechanism (for determining if geometric shapes share an instance of a
> particular class of constraint, e.g. are these two line
> segments perpendicular to each other?)
>
> public function sharesConstraintWith(that:MPShape,
> constraintClass:Class):MPConstraint
> {
> // Get those constraints that are shared between this and that, if there
> are any.
> for each (var c0:MPConstraint in this.constraints)
> {
> for each (var c1:MPConstraint in that.constraints)
> {
> if (c0 == c1 && c0 is constraintClass)
> return c0;
> }
> }
> return null;
> }
>
> It works for me.
> -Eric
>
>
> --- In [email protected] <flexcoders%40yahoogroups.com>, Mark
> Carter <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi Mike - sorry, you've lost me there...
> >
> > The few tests I've done show that "obj is cls" is what I need. Are you
> > saying that does not work?
> >
> >
> > Michael Schmalle wrote:
> > >
> > > Adding to the insight, if you wanted to use the 'is' operator with
> those
> > > two
> > > arguments, you need to create an instance of the Class and then use the
> > > 'is'
> > > operator.
> > > This would let you know if it is an instance of the object passed.
> > >
> > > public static function
> > > isObjectInstanceOfClass(obj:Object, cls:Class):Boolean
> > > {
> > > return obj is new cls();
> > > }
> > >
> > > We have asked the player engineers about the performance hit on this is
> > > not
> > > as bad as describeType in some instances.
> > >
> > >
> > > Mike
> > >
> >
> > --
> > View this message in context:
> http://www.nabble.com/Equivalent-to-Java%27s-Class.isInstance%28Object%29-instance-
> method--tp20171501p20190188.html
> > Sent from the FlexCoders mailing list archive at Nabble.com.
> >
>
>  
>



-- 
Teoti Graphix, LLC
http://www.teotigraphix.com

Teoti Graphix Blog
http://www.blog.teotigraphix.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to