Skip to main content
November 13, 2012
Question

[ISSUE] Load external .swf into an AIR for iOS app

  • November 13, 2012
  • 5 replies
  • 1838 views

I want to load an external .swf which is included theme objects of the application. The loader class finishes loading but after this when I try to get objects in the swf I get this error.

Device is iPad v.2 iOS v5.1.

ReferenceError: Error #1065: Variable MenuHome is not defined.

    at adaptive.controls.thememanager::ApplyTheme/applyStyle()

    at adaptive.controls.thememanager::ApplyTheme/apply()

    at adaptive.controls.thememanager::ThemeManagerSystem/checkIfAllLoaded()

    at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()

    at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()

    at flash.events::EventDispatcher/dispatchEvent()

    at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()

    at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()

    at flash.events::EventDispatcher/dispatchEvent()

    at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()

    at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()

Steps are:

1- Create a .fla file and one object in it (like below):

2- In Flash Builder 4.6

Load the external swf:

                var swfLoader:Loader = new Loader();

                var url:URLRequest = new URLRequest("themes/DefaultTheme/DefaultTheme.swf");

                var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

                swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

                swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

                swfLoader.load(url, loaderContext);

        private function completeHandler(event:Event):void

        {

            var evt:LoadThemeSWFEvent = new LoadThemeSWFEvent(LoadThemeSWFEvent.COMPLETE);

           

            if (AdaptiveHelper.getInstance().platform == PlatformType.DESKTOP)

                evt.swfLoader = SWFLoader(event.currentTarget);

            else

                evt.loader = Loader(event.currentTarget.loader)

                   

            dispatchEvent(evt);

          // load is OK

        }

       

        private function ioErrorHandler(event:IOErrorEvent):void

        {

           

        }

After load is complete I tried to get the object from the swf file and use it as a skin class of a button.

cssSelector.setStyle(property, Class(content.loaderInfo.applicationDomain.getDefinition("MainMenu")));

I am stuck here. Any ideas what the problem is?

My Best,

Suat

This topic has been closed for replies.

5 replies

Nimisha1
Participating Frequently
November 19, 2012

Hi Suat,

Can you send me a sample application  @nimisha1@adobe.com with which I can reproduce your problem and can look into the issue?

Thanks,

Nimisha

November 19, 2012

Thank you Nimisha. I've created a test app and emailed to you.

My Best,

Suat

November 20, 2012

BTW I can get it working on interpreter mode but not on AOT.