In theory, the main app's definition should supercede the module's definition 
unless he loaded the module into a separate appdom instead of the default child 
appdom, but if he did that, I would expect other problems from ModuleLoader.

Note that anytime you specify to load a module directly into the main app's 
appdom, that module cannot be unloaded, so I'd only do things like that in 
special cases.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of Ian Thomas
Sent: Thursday, April 30, 2009 1:22 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Why would "as" keyword not work





Steve,
My guess at what is going on - based on my limited understanding of
what you're doing - is:

- You have your class definition (DetailData) compiled in to your main
application and into your module.
- You load your module into your main application
- Because you have not specifed that you want your module to be in the
same ApplicationDomain as the main application, its class definitions
remain segregated from the main application's class definition.
- Your module creates the DetailData (whether on return from remoting
call or not) by instantiating it's own definition of DetailData (call
it class DetailDataA, if that helps).
- The event fires from your module to your application.
- Your event handler tries to cast the created object - which is of
type DetailDataA - to its _own_ definition of DetailData (call it
class DetailDataB). Hence your error.

No matter that the two class definitions are actually identical -
because they are not in the same ApplicationDomain, the code treats
them as separate.

Now, if you alter your module loading so that you pass in
ApplicationDomain.currentDomain as the domain you want the module to
load into, the problem should go away.
(ModuleLoader.applicationDomain=ApplicationDomain.currentDomain)

I hope that makes some sort of sense. Of course, I may have totally
misunderstood your situation!

HTH,
Ian

On Thu, Apr 30, 2009 at 9:11 PM, valdhor 
<[email protected]<mailto:valdhorlists%40embarqmail.com>> wrote:
>
>
> Alex - I have read your Modules presentation about twenty times so far as
> well as any other documentation I could find on Modules and Application
> Domains. I'm pretty sure I understand everything so far.
>
> Pedro - The ValueObject is only being used by this particular module - not
> by the application (Or any other module).
>
> Ian - All other modules work fine with the exchange data. Note that the
> exchange data and this value object are two different things. I am NOT
> passing this value object as part of the exchange data. The VO gets created
> from a remoteObject call.
>
> All the above being said, I think I have found my problem. The click event
> was handled in the renderer. This works fine in an application but does not
> seem to in a module. By moving the click handler to the datagrid component,
> the error disappears.
>
> This problem crept in whilst I was moving my monolithic app to a series of
> modules.
>
> Thanks for taking the time to push me in the right direction.
>
> Steve
>
> If anyone can enlighten me as to why click events in item renderers work
> differently in modules than applications, please do.
>
> --- In [email protected]<mailto:flexcoders%40yahoogroups.com>, Ian 
> Thomas <i...@...> wrote:
>>
>> As Pedro says - my guess would be that you are passing a DetailData
>> object from one module to the other when you haven't loaded the
>> modules in the same ApplicationDomain (or from one compiled .swf to
>> another, if you're not using modules).
>>
>> Take a look at the documentation for ApplicationDomain.
>>
>> HTH,
>> Ian
>>
>> On Thu, Apr 30, 2009 at 6:18 PM, Pedro Sena <sena.pe...@...> wrote:
>> >
>> >
>> > Are you using modules?
>> >
>> > On Thu, Apr 30, 2009 at 2:17 PM, valdhor <valdhorli...@...>
>> > wrote:
>> >>
>> >>
>> >> Hmmm. Looks like I misspoke. now I get...
>> >>
>> >> Type coercion failed. Cannot convert
>> >> Model.ValueObjects::detaild...@11c0a941 to
>> >> Model.ValueObjects.DetailData.
>> >>
>> >> What is the difference between a
>> >>
>> >> Model.ValueObjects::DetailData
>> >>
>> >> and a
>> >>
>> >> Model.ValueObjects.DetailData
>> >>
>>
>
>

Reply via email to