Yes I agree.  I think the best we can do is to define Class.isSubclassOf 
predicate, something like:

Class.isSubclassOf = function isSubclassOf(classA:Class, classB:Class):Boolean {
  if (classA === Object) { return false; }
  if (classA === classB) { return true; }
  if ($as3) {
    return 
isSubclassOf(flash.utils.getDefinitionByName(flas.utils.getQualifiedSuperclassName(classA)),
 classB);
  } else {
    return classA.prototype is classB;
  }
}

I'm testing this now...    
    
On 2010-01-18, at 08:55, Raju Bitter wrote:

> This might help to retrieve qualified class and superclass name:
> var sprite:Sprite = new Sprite();
> trace(getQualifiedClassName(sprite)); // "flash.display::Sprite"
> //or to retrieve the name of the super class, use:
> trace(getQualifiedSuperclassName(sprite)); // 
> "flash.display::DisplayObjectContainer"
> 
> 
> On Jan 18, 2010, at 2:50 PM, P T Withington wrote:
> 
>> 
>> On 2010-01-18, at 04:34, Rami Ojares / AMG wrote:
>> 
>>> Below is the debug output.
>>> At the bottom is the result of clicking one of the "<Pane>" objects in the 
>>> debugger.
>>> So from that I draw the following conclusions.
>>> 
>>> The argument c (the child) is an object with attributes
>>> - attrs, children (might be missing), class
>>> 
>>> attrs seems to be an object (curly braces)
>>> children seems to be an array (brackets)
>>> class seems to be something special ( less-than, greater-than) I would 
>>> assume this is class (sorry but I don't know exactly what is the 
>>> distinction between class and object in javascript).
>> 
>> I need to write up more about how the debugger represents objects.  
>> Basically, it tries to print a literal representation that is isomorphic to 
>> the actual object.  Javascript is a prototype-based language, and we build 
>> classes and instances on top of the prototyping mechanism.  There is no 
>> literal representation of an object that has a prototype different from 
>> Object.prototype, so the debugger represents such objects in the format 
>> <<"type"#"unique id"| "mnemonic name">>.  It will also use this format if an 
>> object that does have a literal representation is abbreviated due to being 
>> longer than Debug.printLength, or deeper than Debug.printDepth, or contains 
>> circular references.  Finally, if you use the format "%#w", the debugger 
>> will only use the literal representation if the literal representation will 
>> be `==` to the actual object -- any other object will be represented using 
>> the detailed <<>> format.
>> 
>>> So far so good.
>>> The childClass seems to be always something of the form <...> (ie. class)
>>> Like it was supposed to.
>>> 
>>> Then I execute the crucial line
>>> childClass.prototype is lz.Pane
>>> 
>>> But it always returns false...damn.
>> 
>> I think I see the problem.  You must be using swf9/10?  And in that runtime, 
>> the test I described will not work.  Hm.  In fact, I'm not sure how you can 
>> ask if one Class is a subclass of another Class in AS3.  I'll have to 
>> research that!
> 


Reply via email to