Bjorn,

I have been looking at this (as I would like a mocking framework for
Flex too) this evening and I've had no luck either.

The the registerClassAlias() does add the alias to a given class I
can't then get anything to accept it as being of that type
- I'm not sure what the alias is, but dumping the describeType()
results shows it as an alias property on the type and not as an
implementsInterface node, which is what we need.

I may not have been fully understood what registerClassAlias though.

But it looks (ok, it's late and I'm tired so it may just be that which
is causing my negativity) as if trying to get a class to implement an
interface (or at least appear to implement an interface) dynamically
at run time is a futile effort.

Any thoughts?

-D


--- In flexcoders@yahoogroups.com, Bjorn Schultheiss
<[EMAIL PROTECTED]> wrote:
>
> try add
> flash.net.registerClassAlias( "attempt.TestInterface", TestInterface );
> prior to your cast attempt.
> 
> 
> regards,
> 
> Bjorn
> 
> 
> On 17/10/2007, at 1:06 PM, aduston1976 wrote:
> 
> > lus I see a number of places on the web where the idea is mentioned,
> > e.g. http://www.herrodius.com/blog/?m=200704 . However I cannot find
> > any mock frameworks for AS3.
> >
> > This evening I spent some time trying to mock one up on my own (ok,
> > sorry for the pun!) but I ran into troubles. Is anyone interested in
> > thinking about this problem with me?
> >
> > Here is what I did during my 20 minutes of playing:
> >
> > Define an interface:
> >
> > public interface TestInterface
> > {
> > function setSomething(something : String) : void;
> > }
> >
> > Run the following code:
> >
> > public function flexmock() {
> > var i : TestInterface;
> > var c : Class =
> > flash.utils.getDefinitionByName("attempt.TestInterface") as Class;
> > var desc : XML = flash.utils.describeType(c);
> > var str : String = desc.toString();
> > var a : Object = new Object();
> > a["setSomething"] = function(something : String) : void {
> > trace(something); };
> > // will fail on the following line, since a does not implement
> > TestInterface.
> > i = TestInterface(a);
> > i.setSomething("blah");
> > }
> >
> > AS3 doesn't support duck typing like Ruby, and I believe there is no
> > way to get an object in memory that implements the TestInterface
> > interface that my other objects can use as a mock.
> >
> > Any thoughts about this? Am I doomed to use elbow grease or code
> > generation to create these things?
> >
> > BTW, this message is also posted on the ActionScript 3 FlexUnit
> > Library forum in Google Groups. Hopefully that isn't some kind of
> > forum faux pas.
> >
> > Thank you for any comments,
> > Adam
> >
> >
> >
>


Reply via email to