11 Replies Latest reply on Aug 22, 2009 2:03 PM by Flex harUI

    FB4 Modules in AIR

    vivoices Level 1

      The following module loads without problem in a Web (Flash Player) FB4 project:

      package Image_Categories

      {

           import mx.modules.ModuleBase;

           

       

           public class Images extends ModuleBase

           {

       

                [Embed(source="IMG_3652.jpg")]

                public var img001:Class;

       

                public function Images()

                {

                     super();

                }

           }

      }

      I need to make this a Desktop (AIR) project, but when this module loads in AIR, I get following error:

      VerifyError: Error #1014: Class mx.core::BitmapAsset could not be found.

       

           at flash.display::MovieClip/nextFrame()

           at mx.core::FlexModuleFactory/deferredNextFrame()[E:\dev\beta1\frameworks\projects\framework \src\mx\core\FlexModuleFactory.as:530]

           at mx.core::FlexModuleFactory/update()[E:\dev\beta1\frameworks\projects\framework\src\mx\cor e\FlexModuleFactory.as:358]

           at mx.core::FlexModuleFactory/timerHandler()[E:\dev\beta1\frameworks\projects\framework\src\ mx\core\FlexModuleFactory.as:619]

           at flash.utils::Timer/_timerDispatch()

           at flash.utils::Timer/tick()

       

      I tried MXML based modules in AIR as well and get even more errors.

      I tried switching to the 4.0.0.9336 SDK, but FB4 throws an internal error even for new projects created for this SDK.

       

      How can I get this to work in AIR?

        • 1. Re: FB4 Modules in AIR
          Flex harUI Adobe Employee

          Use the -static-rsls option when compiling the project for AIR.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: FB4 Modules in AIR
            vivoices Level 1

            Thank you Alex,

            the -static-rsls compiler options fixed the problem.

             

            Flash Builder should add them automatically when creating modules in an AIR project.

             

            David

            • 3. Re: FB4 Modules in AIR
              Darrell Loverin Level 4

              Would you please file a bug. The default for AIR applications is to be built without RSLs.

               

               

              -Darrell

              • 4. Re: FB4 Modules in AIR
                vivoices Level 1

                Before filing a bug I made a few more tests.

                The following code loads the module fine now with and without the -static-rsls option

                 

                private var mod:IModuleInfo;

                mod = ModuleManager.getModule( "Categories/Categories.swf" );   // <<<

                mod.addEventListener( ModuleEvent.READY, categoriesLoadedHandler );

                mod.load();

                 

                but as soon as I start to load the module via the local webserver

                mod = ModuleManager.getModule( "http://localhost/Categories/Categories.swf" );   // <<<

                The following error is thrown after loading

                 

                VerifyError: Error #1014: Class mx.core::BitmapAsset could not be found.

                 

                     at flash.display::MovieClip/nextFrame()

                     at mx.core::FlexModuleFactory/deferredNextFrame()[E:\dev\beta1\frameworks\projects\framework \src\mx\core\FlexModuleFactory.as:530]

                     at mx.core::FlexModuleFactory/update()[E:\dev\beta1\frameworks\projects\framework\src\mx\cor e\FlexModuleFactory.as:358]

                     at mx.core::FlexModuleFactory/moduleCompleteHandler()[E:\dev\beta1\frameworks\projects\frame work\src\mx\core\FlexModuleFactory.as:605]

                 

                The error is probably related to the embeded bitmaps in the module.

                 

                Why should there be a difference between locations from where the module is loaded?

                How can I get this to work?

                • 5. Re: FB4 Modules in AIR
                  Flex harUI Adobe Employee

                  Check the link-report for the module.  Either the module or the loading applicationdomain must have BitmapAsset linked in.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui

                  1 person found this helpful
                  • 6. Re: FB4 Modules in AIR
                    vivoices Level 1

                    The embeded images all show: - <pre id="mx.core:BitmapAsset" /> - in the link report.

                     

                    The module listed inside the project directory structure shows: - <dep id="mx.core:BitmapAsset" /> -

                    There is a " . . .mx_core_FlexModuleFactory.as" for the module without link to "mx.core:BitmapAsset".

                     

                    Two of the three modules are missing in the report, but as I wrote before, the application functions as expected when I load the modules locally and not through "http:// . . .".

                     

                    - - - - Edit - - - -

                    When I compile the modules without optimization, I do not get the missing mx.core:BitmapAsset error when loading through "http:// . . .", but the "ModuleEvent.READY" event is not firing, so the app is stuck.

                     

                    When I load the modules directly from the bin-debug subfolder, the application runs fine, with and without optimizing the modules.

                     

                    Same behaviour with ModuleLoader (instead of ModuleManager):

                    optimized modules ->  missing mx.core:BitmapAsset error;

                    not optimized -> "ModuleEvent.READY" event is not firing.

                     

                    ? ? ? ?

                    • 7. Re: FB4 Modules in AIR
                      Flex harUI Adobe Employee

                      Sorry, must have missed that you were loading modules over the network in AIR.  That normally doesn't work unless you use loadBytes to load the module and fully trust it.  What are the security implications of the modules?  Do you own them and trust them?

                       

                      Alex Harui

                      Flex SDK Developer

                      Adobe Systems Inc.

                      Blog: http://blogs.adobe.com/aharui

                      • 8. Re: FB4 Modules in AIR
                        vivoices Level 1

                        The modules are completely trustworthy, I write them myself.

                         

                        How do I implement loadBytes to load them over the network properly?

                         

                         

                        Thanks for your help,

                         

                        David

                        • 9. Re: FB4 Modules in AIR
                          Flex harUI Adobe Employee

                          Use URLLoader to load the SWf as a bytearray, use  IModuleInfo.load(appdom, secdom, byteArray) to load the module.

                           

                          Alex Harui

                          Flex SDK Developer

                          Adobe Systems Inc.

                          Blog: http://blogs.adobe.com/aharui

                          1 person found this helpful
                          • 10. Re: FB4 Modules in AIR
                            vivoices Level 1

                            Thank you Alex,

                            the extra step of loading the modules with URLLoader as binary data solved the problem.

                             

                            Does this method use more memory?

                            • 11. Re: FB4 Modules in AIR
                              Flex harUI Adobe Employee

                              That's a good question.  I've never bothered to look.  I keep hoping the next release will include finer grain control over security.  Under the covers, I suspect that the flash.display.Loader has to do pretty much the same thing so I wouldn't expect double the memory.  Maybe I'll run a test one of these days.

                               

                              Alex Harui

                              Flex SDK Developer

                              Adobe Systems Inc.

                              Blog: http://blogs.adobe.com/aharui