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], 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.
>



Reply via email to