[mtasc] Multiple interfaces

Alexandre LEGOUT alexandre.legout at centile.com
Tue Dec 20 17:39:41 CET 2005


The sample code I gave you works now...
I'm really disapointed, I don't know if it's MTASC or SWFViewer from 
FDT, or anything else, but it seems that not all the classes were 
compiled... 8O
It's not the first time for me that I believe that some class are cached 
and not refreshed... Does someone know anything about that ?

But to come back at my problem, the cast in my application *still 
doesn't work* :'(
A class implements 2 interfaces, and each of this interface inherit from 
another interface. The object I want to cast is an instance of the 
implementing class, but I'm unable to cast it to one of the 4 concerned 
interfaces...

In short, my code is the following (a little bit more detailled and near 
from reality than in my first post). Some interfaces names are 
different, but it's exactly the same structure. The most disapointing 
for me is probably that the 'instanceof' return "true", but the cast 
return a 'null' value... :-/

/************ CODE *************/

interface api.data.BaseData {
   function getId():Number;
}

/**/

interface api.data.Contact
     extends api.data.BaseData{
   function getName():String;
   function setName(n:String):Void;
}

/**/

interface api.stack.ISerializable {
  function toString():String;
  // ...
}

/**/

interface api.stack.IXMLSerializable
   extends api.stack.ISerializable {
    function toXML():String;
}

/**/

class ContactImpl
   implements api.data.Contact,
      api.stack.IXMLSerializable {

}

/**/

function receiveEvent(o) {
   var it = o.contact;
   trace("Instance of ContactImpl? " + (it instanceof ContactImpl)); // 
Instance of ContactImpl? true
   trace("Casted to Contact: " + Contact(it)); // Casted to Contact: null
   trace("Casted to BaseData: " + BaseData(it)); // Casted to BaseData: null
   trace("Casted to IXMLSerializable: " + IXMLSerializable(it)); // 
Casted to IXMLSerializable: null
   trace("Casted to ISerializable: " + ISerializable(it)); // Casted to 
ISerializable: null
}

***********************************************

With MMC, the behaviour of this code is the one I was waiting for...

***************** OUTPUT **********************

   // Instance of ContactImpl? true
   // Casted to Contact: [Contact id:"758:1134721681437"]
   // Casted to BaseData: [Contact id:"758:1134721681437"]
   // Casted to IXMLSerializable: [Contact id:"758:1134721681437"]
   // Casted to ISerializable: [Contact id:"758:1134721681437"]

***********************************************

Any ideas ? It's really awful to talk about a bug that I cannot 
reproduce in a "simple" code... :'(
Will continue with untyped object I think... :-(

C ya, ++ ^_^

LAlex

erixtekila a écrit :

> Sorry, but I get a correct output :
> [object Object]
> [object Object]
> [object Object]
>
> I mail you offlist to clear that out.
> But I think it's an mtasc 's version issue…
>
> 6ya
>
>>
> -----------
> erixtekila
> http://blog.v-i-a.net/
>
> -- 
> MTASC : no more coffee break while compiling
>
>





More information about the mtasc mailing list