[flexcoders] Re: Module Interface Problems
Hi! Got the same problem and solution seems to be simple (as mentioned by Alex Harui): before loading module you must set applicationDomain for ModuleLoader (example: moduleTwo.applicationDomain = ApplicationDomain.currentDomain;) Full example is here http://www.yarmak.info/flex/module-to-module.zip Regards, Viktor
[flexcoders] Re: Module Interface Problems
Thanks Alex, that makes total sense now. BTW, great module presentation at 360Flex. I will go look at your slides again. I really appreciate your time on this one :). - Mike --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: OK, I think I see what is going on. The app loads module one into a child domain. MainAppDomain ModuleOneAppDomain The MainAppDomain is where ModuleManager is defined since there is a ModuleLoader and other Module-related code in main.mxml. When ModuleOne goes to load ModuleTwo, it is going to use the ModuleManager code in MainAppDomain which is going to make a child domain from the main app and not moduleOne. MainAppDomain ModuleOneAppDomain ModuleTwoAppDomain Not: MainAppDomain ModuleOneAppDomain ModuleTwoAppDomain And thus you are in the shared code topology. That's why you need to add your interfaces to the main app or use the shared code trick from my blog, or specify the applicationDomain for ModuleOne somehow. -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:11 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, I made a test case and also managed to get it to work. I realized two things about the process. Within the main application I load the module one (red) and module one loads module two (green). Module one needs to be cast as a ModuleLoader in the ready event handler in the Main application in order for module two have a non null pointer. You also seem to have to have the ModuleLoader in the main application cast as the same Interface as the one module two implements. I am not sure why though. Changing either one of these parameters will produce the null pointer. I have a working version of the test case posted, the zip file contains both module one and module two project zip files as well. Example: http://thanksmister.com/moduletest/main.html http://thanksmister.com/moduletest/main.html --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: Can you post a test case? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:00 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, Lol, you said tickling, haha. Yes, this is within the same domain. Everything resides within the bin file of the main application, same level. It was loaded just fine and dispatched the progress and ready events. When you say main class, do you meant the Module that is loading the second module. I got a little lost ModuleLoader loading ModuleLoaders module... makes my head spin. -Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child
[flexcoders] Re: Module Interface Problems
Alex, I made a test case and also managed to get it to work. I realized two things about the process. Within the main application I load the module one (red) and module one loads module two (green). Module one needs to be cast as a ModuleLoader in the ready event handler in the Main application in order for module two have a non null pointer. You also seem to have to have the ModuleLoader in the main application cast as the same Interface as the one module two implements. I am not sure why though. Changing either one of these parameters will produce the null pointer. I have a working version of the test case posted, the zip file contains both module one and module two project zip files as well. Example: http://thanksmister.com/moduletest/main.html --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: Can you post a test case? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:00 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, Lol, you said tickling, haha. Yes, this is within the same domain. Everything resides within the bin file of the main application, same level. It was loaded just fine and dispatched the progress and ready events. When you say main class, do you meant the Module that is loading the second module. I got a little lost ModuleLoader loading ModuleLoaders module... makes my head spin. -Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated
RE: [flexcoders] Re: Module Interface Problems
OK, I think I see what is going on. The app loads module one into a child domain. MainAppDomain ModuleOneAppDomain The MainAppDomain is where ModuleManager is defined since there is a ModuleLoader and other Module-related code in main.mxml. When ModuleOne goes to load ModuleTwo, it is going to use the ModuleManager code in MainAppDomain which is going to make a child domain from the main app and not moduleOne. MainAppDomain ModuleOneAppDomain ModuleTwoAppDomain Not: MainAppDomain ModuleOneAppDomain ModuleTwoAppDomain And thus you are in the shared code topology. That's why you need to add your interfaces to the main app or use the shared code trick from my blog, or specify the applicationDomain for ModuleOne somehow. -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:11 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, I made a test case and also managed to get it to work. I realized two things about the process. Within the main application I load the module one (red) and module one loads module two (green). Module one needs to be cast as a ModuleLoader in the ready event handler in the Main application in order for module two have a non null pointer. You also seem to have to have the ModuleLoader in the main application cast as the same Interface as the one module two implements. I am not sure why though. Changing either one of these parameters will produce the null pointer. I have a working version of the test case posted, the zip file contains both module one and module two project zip files as well. Example: http://thanksmister.com/moduletest/main.html http://thanksmister.com/moduletest/main.html --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: Can you post a test case? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:00 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, Lol, you said tickling, haha. Yes, this is within the same domain. Everything resides within the bin file of the main application, same level. It was loaded just fine and dispatched the progress and ready events. When you say main class, do you meant the Module that is loading the second module. I got a little lost ModuleLoader loading ModuleLoaders module... makes my head spin. -Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03
RE: [flexcoders] Re: Module Interface Problems
Mike, I experienced exactly the same problem. I think it's a bug. Olivier From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 9:40 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002 karnal69@ wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K. - An electronic message is not binding
[flexcoders] Re: Module Interface Problems
Alex, Lol, you said tickling, haha. Yes, this is within the same domain. Everything resides within the bin file of the main application, same level. It was loaded just fine and dispatched the progress and ready events. When you say main class, do you meant the Module that is loading the second module. I got a little lost ModuleLoader loading ModuleLoaders module... makes my head spin. -Mike --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready
RE: [flexcoders] Re: Module Interface Problems
Can you post a test case? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Thursday, April 05, 2007 11:00 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems Alex, Lol, you said tickling, haha. Yes, this is within the same domain. Everything resides within the bin file of the main application, same level. It was loaded just fine and dispatched the progress and ready events. When you say main class, do you meant the Module that is loading the second module. I got a little lost ModuleLoader loading ModuleLoaders module... makes my head spin. -Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui aharui@ wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24
RE: [flexcoders] Re: Module Interface Problems
ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + [EMAIL PROTECTED] wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002 karnal69@ wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002 karnal69@ wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
RE: [flexcoders] Re: Module Interface Problems
If you don't make an instance of the main class in your module which gets around to tickling the module's ModuleLoader, that ModuleLoader won't load its module. Did you see it get loaded and dispatch READY? This is all within a single domain right? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: Wednesday, April 04, 2007 12:40 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems In my context, a module loading another module using ModuleLoader. The reference to the child of the ModuleLoader is always null. I have even set up a timer event that keeps checking back to see if the child is not null. Is there something specific about what I am trying to do that would cause the child to be null? - Mike --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Alex Harui [EMAIL PROTECTED] wrote: ModuleLoader is a convenience container. It loads in the module via ModuleManager and when READY, it starts to create the children. If you listen to READY you may see it before moduleloader had a chance to see it and create the child. -Alex From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: Tuesday, April 03, 2007 1:04 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com , - FI / Jonas Eliasson + jonas.eliasson@ wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002
[flexcoders] Re: Module Interface Problems
From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In flexcoders@yahoogroups.com, kristian_wright2002 [EMAIL PROTECTED] wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
Well scratch those ideas. NO matter what I do the loaded module reports that the ModuleLoader.child is Null. Back to the lab for more experiments. -mr --- In flexcoders@yahoogroups.com, Michael Ritchie [EMAIL PROTECTED] wrote: From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In flexcoders@yahoogroups.com, kristian_wright2002 karnal69@ wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
Using ModuleManager to load the modules allows me to access the Interface methods(in this case 'selectedMedia'). It seems that casting the child within ModuleLoader as an ISoundPlayer interface (in my example) always reports the child as NULL when loaded. However, casting the loaded module as a DisplayObject gives me access to the methods. Example: private var info:IModuleInfo; public var sm:Object; private function initComponent():void { info = ModuleManager.getModule(SoundPlayer.swf); info.addEventListener(ModuleEvent.READY,onLoadComplete) info.addEventListener(ModuleEvent.ERROR,onLoaderError); info.load(); } private function onLoadComplete(event:ModuleEvent):void { trace(Completed and ready); sm = info.factory.create() as DisplayObject; soundPlayer.addChild(sm as DisplayObject); // add to display if( sm != null ) { trace(w, its ready); sm.selectedMedia = _mp3URL; //the function in the interface } else { trace(sound player not ready); } } private function onLoaderError(event:ModuleEvent):void { trace(Problem + event.errorText); } mx:Canvas id=soundPlayer width=100% height=100%/ // Interface package com.custom.interfaces { import flash.events.IEventDispatcher; public interface ISoundPlayer extends IEventDispatcher { function set selectedMedia(mp3URL:String):void; } } - mr --- In flexcoders@yahoogroups.com, kristian_wright2002 [EMAIL PROTECTED] wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
RE: [flexcoders] Re: Module Interface Problems
That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002 [EMAIL PROTECTED] wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
I ruled out the timing issue, but your post has some great information how to handle this. I think I have isolated the specific module loading issue to one factor. I have a module that loads another module using a mx:ModuleLoader and I am trying to access the second ModuleLoader child through the interface. I can't seem get a reference to the child of the second ModuleLoader, it always reports null. I have a successfully loaded a module and talked using the interface, but if move this within the context of another module, I get the null reference. --- In flexcoders@yahoogroups.com, - FI / Jonas Eliasson + [EMAIL PROTECTED] wrote: That sounds like a still existing Flash issue if you try to load a swf that has a shared library attached to it. Then you will get a loaded callback before it's actually loaded. So in Flash you can check on the loaded event if current frame == 0. In that case you can't access any properties and no code will be executed yet. But you can still write to the object. In our scenario we have attached a callback event method. So when the swf is really loaded it will check if the callback exist and then execute it. Which will tell the loader that it's ready to be initiated. Something similar should be easy to implement on the module but not with a check for a frame number :-) . Should be a better solution for this. I don't want to go back to old Flash hacks hehe. //as2 example private function onLibraryLoaded(libraryClip:MovieClip, cb:CallBack):Void { var me:SharedLibraryLoader = getInstance(); if(libraryClip._currentframe == 0){ libraryClip.onComplete = new CallBack(me, me.onLibraryInitiated, null, cb); }else onLibraryInitiated(libraryClip, cb); } _ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Ritchie Sent: den 3 april 2007 11:24 To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Module Interface Problems From my experience there is a definite timing issue when loading modules. The ModuleLoader ready event is fired before the Module is fully loaded and you have the ability to talk to it through a common interface (hence the error reporting access to a null value). I would term this one as a bug that is not yet documented by Adobe. This could be because some modules take longer than expected to load, I have no idea, just the observed problem with talking with modules within the ready. I also attempted to use an interface to talk with a module when the the progress event had reached 100%, but still no luck. A possible workaround would be to fire some event from inside the loaded module that tells the outside world that it is indeed loaded. The other option is to set a timer interval and keep checking if the module is loaded (meaning not reporting NULL in the ready event handler). Unless someone else as a viable solution? Adobe? Anyone? - mr --- In [EMAIL PROTECTED] mailto:flexcoders%40yahoogroups.com ups.com, kristian_wright2002 karnal69@ wrote: *BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
*BUMP* Anyone have any ideas? I still haven't found a solution... K.
[flexcoders] Re: Module Interface Problems
Tried strong typing, but no luck! Thanks though! K. --- In flexcoders@yahoogroups.com, Roger Gonzalez [EMAIL PROTECTED] wrote: For what its worth, it appears at first glance that your code should work. Have you tried strong typing rather than using *? var results:IResults= IResults(modMyModule2.child) Not sure why it isn't working though, sorry. -rg
[flexcoders] Re: Module Interface Problems
I tried the following: private function readyModule(evt:Event):void { modResult = new Object; modResult = modMyModule2.child as IResults; if (modResult.searchResults==null){trace(NULL!);} else{trace(NOT NULL!);} modResult.searchResults = arrSearchResults; } but it crashes at the 'if' statement with Cannot access a property or method of a null object reference I'm not sure what you mean though by Also if you are using an Interface you need to reference the Interface within both the Application and the Module. I have the interface referenced in the second module via 'implements=IResults', but do I need another reference in the calling module besides var ichild:* = modMyModule2.child as IResults; ichild.searchResults = arrSearchResults; ?? The documentation doesn't seem to state anything regarding referencing the interface in the application other than this... Thanks again, K. --- In flexcoders@yahoogroups.com, lar.drolet [EMAIL PROTECTED] wrote: Try this: public var modResult:Object; private function onModuleReady( event:Event ):void { modResult = (modMyModule2.child as myResults); modResult.searchResults = arrSearchResults; } Also if you are using an Interface you need to reference the Interface within both the Application and the Module. Check out this blog for some more information: http://weblogs.macromedia.com/pent/ Good Luck. LD
[flexcoders] Re: Module Interface Problems
Try this: public var modResult:Object; private function onModuleReady( event:Event ):void { modResult = (modMyModule2.child as myResults); modResult.searchResults = arrSearchResults; } Also if you are using an Interface you need to reference the Interface within both the Application and the Module. Check out this blog for some more information: http://weblogs.macromedia.com/pent/ Good Luck. LD --- In flexcoders@yahoogroups.com, Roger Gonzalez [EMAIL PROTECTED] wrote: For what its worth, it appears at first glance that your code should work. Have you tried strong typing rather than using *? var results:IResults= IResults(modMyModule2.child) Not sure why it isn't working though, sorry. -rg