开发者

Loading image from external domain in Flash AS3

I have to load XML from external domain, so my code looks like this

var loader:URLLoader = new URLLoader();
        configureListeners(loader);

        var request:URLRequest = new URLRequest("http://demo.softsolutions4u.com/ss4uplayer/modules/podcast/lib/PlayerAPI.php");
        try {
            loader.load(request);
        } catch (error:Error) {
   开发者_开发百科         trace("Unable to load requested document.");
        }

        function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
         }

        function completeHandler(event:Event):void {
            var loader:URLLoader = URLLoader(event.target);
            trace("completeHandler: " + loader.data);
            datas.appendText("completeHandler: " +loader.data);
        }


        function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
            datas.appendText("securityErrorHandler: " +event);
        }

But it throws exception at run time

securityErrorHandler: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://192.168.2.55/onlinemovie/Development/SS4UPlayer310310/test.swf cannot load data from http://demo.softsolutions4u.com/ss4uplayer/modules/podcast/lib/PlayerAPI.php."

Crossdomain XML file also loaded and security allodomain is in(*). Please tell me what I missed here.


its not like that. We are not going to use the flash swf file, but our 'N' no of clients going to use this swf in their server, so then in that case how could i place the crossdomain.xml. I dont know where i should put it. Please help me to fix it.


Try adding this line

Security.allowInsecureDomain("demo.softsolutions4u.com");

You should be able to test the movie ONLY inside the Flash IDE or on the client server


I don't see crossdomain.xml at the location http://demo.softsolutions4u.com/crossdomain.xml, it returns a 404 error. You should place the crossdomain.xml at the root of the domain and try again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜