Relative URL from SWF

by 9re forked from Passing String to the Constructor of Date Class (diff: 21)
An access to relative URL from SWF is relative to the URL of HTML and not to the URL of SWF.

So if you paste this SWF to blogs which have '/index.xml' as RSS, the blog entry will listed.

♥0 | Line 44 | Modified 2010-09-02 11:49:45 | MIT License
play

ActionScript3 source code

/**
 * Copyright 9re ( http://wonderfl.net/user/9re )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/brRp
 */

<?xml version="1.0" encoding="utf-8"?>
<!-- forked from 9re's Passing String to the Constructor of Date Class -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" paddingBottom="0" paddingLeft="0" paddingTop="0" paddingRight="0">
<mx:ArrayCollection id="feed" />
<mx:DataGrid id="reader" width="100%" height="100%" change='navigateToURL(new URLRequest(reader.selectedItem.link), "_blank")'>
    <mx:columns>
        <mx:DataGridColumn dataField="title"/>
        <mx:DataGridColumn dataField="日付" width="150" />
    </mx:columns>
</mx:DataGrid>
<mx:Script><![CDATA[
import flash.events.*;
import flash.net.*;
import mx.controls.Alert;
private function init():void {
    var req:URLRequest = new URLRequest;
    req.url = '/index.xml'; // <- relative url
    var ldr:URLLoader = new URLLoader;
    ldr.addEventListener(Event.COMPLETE, function complete(e:Event):void {
        ldr.removeEventListener(Event.COMPLETE, complete);
        onRSSLoaded(XML(ldr.data));
    });
    ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, showError);
    ldr.addEventListener(IOErrorEvent.IO_ERROR, showError);
    ldr.load(req);
}
private function showError(e:ErrorEvent):void {
    Alert.show(e.text, e.type);
}
private function onRSSLoaded(rss:XML):void {
    var data:Array = [];
    for each (var item:XML in rss.channel.item) {
        // pass string to Date constructor
        var date:Date = new Date(item.pubDate.toString());
        data.push( {
            title : item.title,
            link  : item.link,
            日付 : date.fullYear + '年' + (date.month + 1) + '月' + date.date + '日 ' + date.hours + '時'
        });
    }
        
    feed.source = data;
    reader.dataProvider = feed;
}
]]></mx:Script>
</mx:Application>