0

My company design digital signage solutions for companies. The animated widgets are typically produced in Flash.

In a current project I'm experiencing a bit of an odd issue. The screen is split into 3 areas: Video, RSS Ticker, and Weather. The RSS and Weather objects are created using Flash. Each object is it's own Flash file.

Both Flash object utilize the same method to connect to the remote servers:

function loadWeatherFromUrl():void
{
    var urlRequest:URLRequest  = new URLRequest("MY URL");

    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, completeHandler);

    try{
        urlLoader.load(urlRequest);
    } catch (error:Error) {
        trace("Cannot load : " + error.message);
    }
}

function completeHandler(event:Event):void {
    var loader:URLLoader = URLLoader(event.target);
    //Do stuff with the data...
}

When testing in the IDE, both the Weather object and the RSS object work fine, as seen below:

Working RSS object

Once deployed to the signage software it doesn't work anymore. However, the Weather object works as expected. The Flash object doesn't encounter a URL loading error either. Compare pic #2 and pic #3 to see how I view errors.

Image of signage application

If I try to preview both the Weather object and the RSS object locally in a web-browser (IE, Firefox), I do get local permission errors, as expected.

Permission error

So any ideas why one would work and the other wouldn't? If it had something to do with CORS (Cross Origin Resource Sharing) wouldn't both fail? I have tried both options (local only / network only) in the Publish -> Playback settings.

The weather object is powered by Yahoo:

Yahoo Weather

and the RSS object is powered by CTV News (Canadian Television Network):

CTV RSS Feed

EDIT:

For the RSS feed (above I used the Weather object's methods, they're identical except the function name and error output) I have the following:

At run time

error_msg.text = "Loading...";

Then the URL loading:

function loadFeedFromUrl():void
{
    var urlRequest:URLRequest  = new URLRequest("http://ottawa.ctvnews.ca/rss/ctv-news-ottawa-1.1245493");
    error_msg.text = "";
    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, completeHandler);
    try{
        urlLoader.load(urlRequest);
    } catch (error:Error) {
        trace("Cannot load : " + error.message);
        error_msg.text = error.message;
    }
}

EDIT #2

Here is the UPDATED loading function, as well as the basic error handling functions.

function loadFeedFromUrl():void
{
    var urlRequest:URLRequest  = new URLRequest("http://ottawa.ctvnews.ca/rss/ctv-news-ottawa-1.1245493");
    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, completeHandler);
    try{
        urlLoader.load(urlRequest);
    } catch (error:Error) {
        trace("Cannot load : " + error.message);
        error_msg.text = error.message;
    }
    urlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandlerFunction);
    urlLoader.addEventListener(IOErrorEvent.NETWORK_ERROR, ioErrorHandlerFunction);
    urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandlerFunction);
}

function ioErrorHandlerFunction() {
    error_msg.text = "IO Error!";
}

function securityErrorHandlerFunction() {
    error_msg.text = "Security Error!";
}

The error_msg textfield stays "Loading...", so it doesn't appear any of those error types are being received.

matcartmill
  • 1,573
  • 2
  • 19
  • 38
  • How is that Error output in image #3 generated with the code you posted? – null Apr 29 '15 at 16:44
  • Please see the edit to the original question. Thanks. – matcartmill Apr 29 '15 at 16:49
  • Are your dev machine and signage machine on the same network with the same firewalls and proxy's? Are you exporting with the right network settings (Remote Only) in flash? – BadFeelingAboutThis Apr 29 '15 at 16:54
  • Yes, and we also have a web back-end for publishing content and previewing layouts, and the preview there is the same: Weather works, RSS doesn't and has no errors. – matcartmill Apr 29 '15 at 16:55
  • @matcartmill. Thank you. It looks like `load()` is indeed executed without throwing an error. [But there are a few Events indicating an Error, too](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#load%28%29) What happens if you listen for those? – null Apr 29 '15 at 16:59
  • Indeed, listen for Security Errors, Network Errors and IO Errors. See my (and the other) answer to this question: http://stackoverflow.com/questions/27572684/as3-http-get-doesnt-work/27573334#27573334 – BadFeelingAboutThis Apr 29 '15 at 17:02
  • Hi guys, please see Edit #2. Added the listeners, getting no errors still. – matcartmill Apr 29 '15 at 17:18
  • You could also try adding: `urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);` and see what you get from that. - Also, you should add those events **before** calling `urlLoader.load` – BadFeelingAboutThis Apr 29 '15 at 17:52
  • Also, you should get errors because you have no event parameters on your `ioErrorHandlerFunction` and `securityErrorHandlerFunction()`. When adding the HTTP_Status event, append your `error_msg.text` with the event's status property – BadFeelingAboutThis Apr 29 '15 at 18:05
  • Thanks. Here's what I get for the HTTP STATUS print out: `[HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=0 redirected=false responseURL=null]` – matcartmill Apr 29 '15 at 18:07
  • How does your signage load flash? via an HTML wrapper? This likely has something to do with CORS or the context of how the swf is loaded. Strange though you should be getting a security error. Can you tweak your second edit to include the code your are now using. Sometimes an status of 0 can mean there is nothing found on the other end. – BadFeelingAboutThis Apr 29 '15 at 18:24
  • It's a CORS issue. I copied the XML to my dev server and added a crossdomain.xml file to the root. Started working at that point. I thought for sure that would have generated a security error, though. Thanks for your help. – matcartmill Apr 29 '15 at 18:51

0 Answers0