Question

I'm working in a flash CS6 and I'm having a trouble: After calling a function, player freezes at frame 1. This not happend during Ctrl+ENTER preview, but when I play the .swf file published (using flash player or opening it on a web browser, doesn't matter) is when the problem begin.

This is the code:

import flash.display.MovieClip;
var code:int = 0
var temp:int = 0; 
var _xmlURL:String = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid=368335%20and%20u=%27c%27";
var _xmlData:XML;

function loadXML(xmlURL:String):void {
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest(_xmlURL);
    loader.load(request);
    loader.addEventListener(Event.COMPLETE, loadData);
}

function loadData(event:Event):void{
    _xmlData = new XML(event.currentTarget.data);

    var dataG:XMLList = _xmlData.results.channel.item.elements();

    code = dataG[5].@code;
    temp = dataG[5].@temp;

    trace(code);
    trace(temp);
}

loadXML(_xmlURL);

I'm not used to use as3, I don't know if I'm using it right.

As you can see, the code reads an external xml file using "URLLoader" and its method ".load".

Thanks for your help.

BTW, I've already tried to play the published ".swf" file in other PCs (xp, seven, 8), one of them with Windows recently installed (seven).

Was it helpful?

Solution

Most likely (because you're loading in resources from the internet, and it works when you test), this has to do with the security settings of your application.

Go to your publish settings file -> publish settings.

You'll see a drop down labelled Local playback security. Ensure this is set to access network only and not the default acess local only.

This hangs up a lot of people when they first start using flash.


It's always good practice too, to listen not just for the COMPLETE event on your loaders, but also for error events such as:

loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandlerFunction);
loader.addEventListener(IOErrorEvent.NETWORK_ERROR, ioErrorHandlerFunction);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandlerFunction);

In your case, it's probably throwing a security error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top