简体   繁体   中英

AS3 iOS : Loading external swf

I'm trying to load a swf in another using AIR3.6. I duplicated the code I found here http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/ but in vain. It does'nt work. So I think I didn't understand part of the procedure.

That what I have done :

• I have a first fla I can correctly publish for iOS.

• In this fla I have this code :

        var mLoader:Loader = new Loader();
        var mRequest:URLRequest = new URLRequest("test.swf");
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

        mLoader.load(mRequest);
        function onCompleteHandler(loadEvent:Event)
        {
            addChild(loadEvent.currentTarget.content);
        }

• In the publish settings I went to the General tab and I included my second swf : test.swf

• The second swf (test.swf). I published it with AIR 3.6 for iOS. It has no actionscript at all. There is only a green shape in it.

• When I test my first fla, the second one is correctly loaded.

• When I publish it in my iPad, the second swf is NOT loaded.

Can someone tells me where I was wrong ?

Thanks.

All right, 10 seconds after publishing my question, I found my solution. I only forgot to put the _lc:LoaderContext in the mLoader.load(). So here is it :

    var mLoader:Loader = new Loader();
    var mRequest:URLRequest = new URLRequest("test.swf");
    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);

    mLoader.load(mRequest, _lc);
    function onCompleteHandler(loadEvent:Event)
    {
        addChild(loadEvent.currentTarget.content);
    }

Note to moderators : Not sure this will be helpfull for anyone, but I don't know how to delete a post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM