In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

XMLからデータを読み込む

ここ読むといいよ。
http://yapr.seesaa.net/article/43701070.html
http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/XML.html
Get Adobe Flash player
by takimo 25 Feb 2009
package {
    /*
    ここ読むといいよ。
    http://yapr.seesaa.net/article/43701070.html
    http://help.adobe.com/ja_JP/AS3LCR/Flash_10.0/XML.html
    */
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequest;
    import flash.text.TextField;
    public class KakakuSearch extends Sprite {
        private var _xml:XML = new XML();
        private var _xmlLoader:URLLoader = new URLLoader();
        private var _url:String = "http://api.kakaku.com/Ver1/ItemSearch.asp?Keyword=%83o%83C%83I&CategoryGroup=pc&ResultSet=medium&SortOrder=pricerank&PageNum=1";
        /*
        ↑上のURLみるとこんな感じのXMLがみれるはず
        <ProductInfo>
            <NumOfResult>1339</NumOfResult>
            −
            <Item>
                <ProductID>01602011643</ProductID>
                <ProductName>MUS-CKT49V (バイオレット)</ProductName>
                <MakerName>ロアス</MakerName>
                <CategoryName>パソコン>マウス</CategoryName>
                <PvRanking>1395</PvRanking>
                −
                <ImageUrl>
                    http://img.kakaku.com/images/productimage/m/01602011643.jpg 
                </ImageUrl>
                <ItemPageUrl>http://kakaku.com/item/01602011643/</ItemPageUrl>
                <BbsPageUrl>http://bbs.kakaku.com/bbs/01602011643/</BbsPageUrl>
                <ReviewPageUrl>http://review.kakaku.com/review/01602011643/</ReviewPageUrl>
                <LowestPrice>1494</LowestPrice>
                <NumOfBbs/>
            </Item>
        */
        
        public function KakakuSearch() {
            var request:URLRequest = new URLRequest(_url);
            _xmlLoader.addEventListener(Event.COMPLETE, displayItem);
            _xmlLoader.load(request);
        }

        private function displayItem(e:Event):void
        {
            var itemBox:TextField = new TextField();
            itemBox.x = 100;
            itemBox.y = 50;
            itemBox.width = 300;
            itemBox.height = 300;
            itemBox.border = true;
            addChild(itemBox);

            _xml = new XML(_xmlLoader.data);
            
            //この_xml.ItemっていうのはXMLの中の<Item>
            for each(var item:Object in _xml.Item)
            {
                itemBox.appendText("name : " + item.ProductName + "\n");
            }
            
        }
    }
}